~devcamcar/horizon/trunk

« back to all changes in this revision

Viewing changes to django-openstack/src/django_openstack/nova/views/regions.py

  • Committer: Devin Carlen
  • Date: 2011-06-18 05:59:37 UTC
  • Revision ID: devin.carlen@gmail.com-20110618055937-aobwm0buvviijz3o
Moved codebase to GitHub

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
 
# Copyright 2010 United States Government as represented by the
4
 
# Administrator of the National Aeronautics and Space Administration.
5
 
# All Rights Reserved.
6
 
#
7
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
8
 
#    not use this file except in compliance with the License. You may obtain
9
 
#    a copy of the License at
10
 
#
11
 
#         http://www.apache.org/licenses/LICENSE-2.0
12
 
#
13
 
#    Unless required by applicable law or agreed to in writing, software
14
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
 
#    License for the specific language governing permissions and limitations
17
 
#    under the License.
18
 
 
19
 
"""
20
 
Views for managing Nova regions.
21
 
"""
22
 
 
23
 
from django.contrib import messages
24
 
from django.contrib.auth.decorators import login_required
25
 
from django.shortcuts import redirect
26
 
from django.utils.translation import ugettext as _
27
 
from django_openstack import log as logging
28
 
from django_openstack.nova.shortcuts import set_current_region
29
 
 
30
 
 
31
 
LOG = logging.getLogger('django_openstack.nova')
32
 
 
33
 
 
34
 
@login_required
35
 
def change(request):
36
 
    region = request.POST['region']
37
 
    redirect_url = request.POST['redirect_url']
38
 
    set_current_region(request, region)
39
 
    messages.success(request, _('You are now using the region "%s".') % region)
40
 
    LOG.info('User "%s" changed to region "%s"' % (str(request.user), region))
41
 
    return redirect(redirect_url)