diff -r 4ab56ec63b95 -r 508783ea7dc1 django/contrib/auth/admin.py
a
|
b
|
|
1 | | from django import template |
2 | 1 | from django.db import transaction |
3 | 2 | from django.conf import settings |
4 | 3 | from django.contrib import admin |
… |
… |
|
13 | 12 | from django.utils.decorators import method_decorator |
14 | 13 | from django.utils.translation import ugettext, ugettext_lazy as _ |
15 | 14 | from django.views.decorators.csrf import csrf_protect |
| 15 | from django.utils.encoding import force_unicode |
16 | 16 | |
17 | 17 | csrf_protect_m = method_decorator(csrf_protect) |
18 | 18 | |
… |
… |
|
103 | 103 | extra_context.update(defaults) |
104 | 104 | return super(UserAdmin, self).add_view(request, form_url, extra_context) |
105 | 105 | |
| 106 | def response_add(self, request, obj, post_url_continue='../%s/'): |
| 107 | """ |
| 108 | Determines the HttpResponse for the add_view stage. It mostly |
| 109 | defers to its superclass implementation but is slightly |
| 110 | customized because the User model has a different workflow. |
| 111 | """ |
| 112 | opts = obj._meta |
| 113 | pk_value = obj._get_pk_val() |
| 114 | |
| 115 | msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj)} |
| 116 | # Here, we distinguish between different save types by checking for |
| 117 | # the presence of keys in request.POST. |
| 118 | if request.POST.has_key("_addanother"): |
| 119 | self.message_user(request, msg + ' ' + (_("You may add another %s below.") % force_unicode(opts.verbose_name))) |
| 120 | return HttpResponseRedirect(request.path) |
| 121 | else: |
| 122 | return super(UserAdmin, self).response_add(request, obj, post_url_continue) |
| 123 | |
106 | 124 | def user_change_password(self, request, id): |
107 | 125 | if not self.has_change_permission(request): |
108 | 126 | raise PermissionDenied |