Ticket #8670: auth_add_view.diff

File auth_add_view.diff, 1.4 KB (added by sorl, 7 years ago)
  • contrib/auth/admin.py

    old new  
    4141            return self.user_change_password(request, url.split('/')[0])
    4242        return super(UserAdmin, self).__call__(request, url)
    4343
    44     def add_view(self, request):
     44    def add_view(self, request, extra_context=None):
    4545        if not self.has_change_permission(request):
    4646            raise PermissionDenied
    4747        if request.method == 'POST':
     
    5858                    return HttpResponseRedirect('../%s/' % new_user.id)
    5959        else:
    6060            form = self.add_form()
    61         return render_to_response('admin/auth/user/add_form.html', {
     61        context = {
    6262            'title': _('Add user'),
    6363            'form': form,
    6464            'is_popup': '_popup' in request.REQUEST,
     
    7575            'username_help_text': self.model._meta.get_field('username').help_text,
    7676            'root_path': self.admin_site.root_path,
    7777            'app_label': self.model._meta.app_label,           
    78         }, context_instance=template.RequestContext(request))
     78        }
     79        context.update(extra_context or {})
     80        return render_to_response('admin/auth/user/add_form.html', context,
     81                context_instance=template.RequestContext(request))
    7982
    8083    def user_change_password(self, request, id):
    8184        if not request.user.has_perm('auth.change_user'):
Back to Top