Code

Ticket #8670: auth_add_view.diff

File auth_add_view.diff, 1.4 KB (added by sorl, 6 years ago)
Line 
1--- django.org/contrib/auth/admin.py    2008-08-29 00:15:29.000000000 +0200
2+++ django/contrib/auth/admin.py        2008-08-29 00:27:05.000000000 +0200
3@@ -41,7 +41,7 @@
4             return self.user_change_password(request, url.split('/')[0])
5         return super(UserAdmin, self).__call__(request, url)
6 
7-    def add_view(self, request):
8+    def add_view(self, request, extra_context=None):
9         if not self.has_change_permission(request):
10             raise PermissionDenied
11         if request.method == 'POST':
12@@ -58,7 +58,7 @@
13                     return HttpResponseRedirect('../%s/' % new_user.id)
14         else:
15             form = self.add_form()
16-        return render_to_response('admin/auth/user/add_form.html', {
17+        context = {
18             'title': _('Add user'),
19             'form': form,
20             'is_popup': '_popup' in request.REQUEST,
21@@ -75,7 +75,10 @@
22             'username_help_text': self.model._meta.get_field('username').help_text,
23             'root_path': self.admin_site.root_path,
24             'app_label': self.model._meta.app_label,           
25-        }, context_instance=template.RequestContext(request))
26+        }
27+        context.update(extra_context or {})
28+        return render_to_response('admin/auth/user/add_form.html', context,
29+                context_instance=template.RequestContext(request))
30 
31     def user_change_password(self, request, id):
32         if not request.user.has_perm('auth.change_user'):