~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to django/contrib/auth/admin.py

  • Committer: Package Import Robot
  • Author(s): Luke Faraone
  • Date: 2013-11-07 15:33:49 UTC
  • mfrom: (1.3.12)
  • Revision ID: package-import@ubuntu.com-20131107153349-e31sc149l2szs3jb
Tags: 1.6-1
* New upstream version. Closes: #557474, #724637.
* python-django now also suggests the installation of ipython,
  bpython, python-django-doc, and libgdal1.
  Closes: #636511, #686333, #704203
* Set package maintainer to Debian Python Modules Team.
* Bump standards version to 3.9.5, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from django.db import transaction
2
2
from django.conf import settings
3
3
from django.contrib import admin
 
4
from django.contrib.admin.options import IS_POPUP_VAR
4
5
from django.contrib.auth.forms import (UserCreationForm, UserChangeForm,
5
6
    AdminPasswordChangeForm)
6
7
from django.contrib.auth.models import User, Group
92
93
 
93
94
    @sensitive_post_parameters_m
94
95
    @csrf_protect_m
95
 
    @transaction.commit_on_success
 
96
    @transaction.atomic
96
97
    def add_view(self, request, form_url='', extra_context=None):
97
98
        # It's an error for a user to have add permission but NOT change
98
99
        # permission for users. If we allowed such users to add users, they
125
126
    def user_change_password(self, request, id, form_url=''):
126
127
        if not self.has_change_permission(request):
127
128
            raise PermissionDenied
128
 
        user = get_object_or_404(self.queryset(request), pk=id)
 
129
        user = get_object_or_404(self.get_queryset(request), pk=id)
129
130
        if request.method == 'POST':
130
131
            form = self.change_password_form(user, request.POST)
131
132
            if form.is_valid():
132
133
                form.save()
 
134
                change_message = self.construct_change_message(request, form, None)
 
135
                self.log_change(request, request.user, change_message)
133
136
                msg = ugettext('Password changed successfully.')
134
137
                messages.success(request, msg)
135
138
                return HttpResponseRedirect('..')
144
147
            'adminForm': adminForm,
145
148
            'form_url': form_url,
146
149
            'form': form,
147
 
            'is_popup': '_popup' in request.REQUEST,
 
150
            'is_popup': IS_POPUP_VAR in request.REQUEST,
148
151
            'add': True,
149
152
            'change': False,
150
153
            'has_delete_permission': False,
171
174
        # button except in two scenarios:
172
175
        # * The user has pressed the 'Save and add another' button
173
176
        # * We are adding a user in a popup
174
 
        if '_addanother' not in request.POST and '_popup' not in request.POST:
 
177
        if '_addanother' not in request.POST and IS_POPUP_VAR not in request.POST:
175
178
            request.POST['_continue'] = 1
176
179
        return super(UserAdmin, self).response_add(request, obj,
177
180
                                                   post_url_continue)