Ticket #6977: 6977.patch

File 6977.patch, 1.5 KB (added by mk, 7 years ago)
  • django/contrib/auth/admin.py

    diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
    index f97935d..41458e4 100644
    a b class UserAdmin(admin.ModelAdmin): 
    2828    def add_view(self, request):
    2929        # avoid a circular import. see #6718.
    3030        from django.contrib.auth.forms import UserCreationForm
    31         if not self.has_change_permission(request):
     31        if not self.has_add_permission(request):
    3232            raise PermissionDenied
     33
    3334        if request.method == 'POST':
    3435            form = UserCreationForm(request.POST)
    3536            if form.is_valid():
    class UserAdmin(admin.ModelAdmin): 
    4041                    return HttpResponseRedirect(request.path)
    4142                else:
    4243                    request.user.message_set.create(message=msg + ' ' + ugettext("You may edit it again below."))
    43                     return HttpResponseRedirect('../%s/' % new_user.id)
     44
     45                    if self.has_change_permission(request, None):
     46                        # redirect to change view
     47                        post_url = '../%s/' % new_user.id
     48                    else:
     49                        # Object list will give 'Permission Denied', so go back to admin home
     50                        post_url = '../../../'
     51
     52                    return HttpResponseRedirect(post_url)
    4453        else:
    4554            form = UserCreationForm()
    4655        return render_to_response('admin/auth/user/add_form.html', {
Back to Top