Ticket #10759: admin_user_template_vars.diff
File admin_user_template_vars.diff, 3.4 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/admin.py
32 32 ordering = ('username',) 33 33 filter_horizontal = ('user_permissions',) 34 34 35 # Custom templates (designed to be over-ridden in subclasses) 36 add_form_template = None 37 change_password_template = None 38 35 39 def __call__(self, request, url): 36 40 # this should not be here, but must be due to the way __call__ routes 37 41 # in ModelAdmin. … … 76 80 return HttpResponseRedirect('../%s/' % new_user.id) 77 81 else: 78 82 form = self.add_form() 79 return render_to_response('admin/auth/user/add_form.html', { 83 84 context = { 80 85 'title': _('Add user'), 81 86 'form': form, 82 87 'is_popup': '_popup' in request.REQUEST, … … 93 98 'username_help_text': self.model._meta.get_field('username').help_text, 94 99 'root_path': self.admin_site.root_path, 95 100 'app_label': self.model._meta.app_label, 96 } , context_instance=template.RequestContext(request))101 } 97 102 103 return render_to_response(self.add_form_template or [ 104 'admin/%s/%s/add_form.html' % (self.opts.app_label, self.opts.object_name.lower()), 105 'admin/auth/user/add_form.html', 106 ], context, context_instance=template.RequestContext(request)) 107 98 108 def user_change_password(self, request, id): 99 109 if not request.user.has_perm('auth.change_user'): 100 110 raise PermissionDenied … … 108 118 return HttpResponseRedirect('..') 109 119 else: 110 120 form = self.change_password_form(user) 111 return render_to_response('admin/auth/user/change_password.html', { 112 'title': _('Change password: %s') % escape(user.username), 113 'form': form, 114 'is_popup': '_popup' in request.REQUEST, 115 'add': True, 116 'change': False, 117 'has_delete_permission': False, 118 'has_change_permission': True, 119 'has_absolute_url': False, 120 'opts': self.model._meta, 121 'original': user, 122 'save_as': False, 123 'show_save': True, 124 'root_path': self.admin_site.root_path, 125 }, context_instance=RequestContext(request)) 121 122 context = { 123 'title': _('Change password: %s') % escape(user.username), 124 'form': form, 125 'is_popup': '_popup' in request.REQUEST, 126 'add': True, 127 'change': False, 128 'has_delete_permission': False, 129 'has_change_permission': True, 130 'has_absolute_url': False, 131 'opts': self.model._meta, 132 'original': user, 133 'save_as': False, 134 'show_save': True, 135 'root_path': self.admin_site.root_path, 136 } 126 137 138 return render_to_response(self.change_password_template or [ 139 'admin/%s/%s/change_password.html' % (self.opts.app_label, self.opts.object_name.lower()), 140 'admin/auth/user/change_password.html', 141 ], context, context_instance=RequestContext(request)) 127 142 143 128 144 admin.site.register(Group, GroupAdmin) 129 145 admin.site.register(User, UserAdmin) 130 146