Ticket #14014: 14014.diff

File 14014.diff, 1.8 KB (added by Ramiro Morales, 14 years ago)

A possible fix for this issue

  • django/contrib/auth/admin.py

    diff -r 4ab56ec63b95 -r 508783ea7dc1 django/contrib/auth/admin.py
    a b  
    1 from django import template
    21from django.db import transaction
    32from django.conf import settings
    43from django.contrib import admin
     
    1312from django.utils.decorators import method_decorator
    1413from django.utils.translation import ugettext, ugettext_lazy as _
    1514from django.views.decorators.csrf import csrf_protect
     15from django.utils.encoding import force_unicode
    1616
    1717csrf_protect_m = method_decorator(csrf_protect)
    1818
     
    103103        extra_context.update(defaults)
    104104        return super(UserAdmin, self).add_view(request, form_url, extra_context)
    105105
     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
    106124    def user_change_password(self, request, id):
    107125        if not self.has_change_permission(request):
    108126            raise PermissionDenied
Back to Top