Ticket #8493: 8493_special_admin_password_change.1.diff

File 8493_special_admin_password_change.1.diff, 4.4 KB (added by Brian Rosner, 16 years ago)

better patch that has a new feature side-effect

  • django/contrib/admin/sites.py

    diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
    index 7e94bbf..9d0c65d 100644
    a b class AdminSite(object):  
    194194        Handles the "change password" task -- both form display and validation.
    195195        """
    196196        from django.contrib.auth.views import password_change
    197         return password_change(request)
     197        return password_change(request,
     198            post_save_redirect='%spassword_change/done/' % self.root_path)
    198199
    199200    def password_change_done(self, request):
    200201        """
  • django/contrib/auth/views.py

    diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
    index 43693d6..a074f22 100644
    a b def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_N  
    7373
    7474def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html',
    7575        email_template_name='registration/password_reset_email.html',
    76         password_reset_form=PasswordResetForm, token_generator=default_token_generator):
     76        password_reset_form=PasswordResetForm, token_generator=default_token_generator,
     77        post_rest_redirect=None):
     78    if post_reset_redirect is None:
     79        post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done')
    7780    if request.method == "POST":
    7881        form = password_reset_form(request.POST)
    7982        if form.is_valid():
    def password_reset(request, is_admin_site=False, template_name='registration/pas  
    8790                if not Site._meta.installed:
    8891                    opts['domain_override'] = RequestSite(request).domain
    8992            form.save(**opts)
    90             return HttpResponseRedirect(reverse('django.contrib.auth.views.password_reset_done'))
     93            return HttpResponseRedirect(post_reset_redirect)
    9194    else:
    9295        form = password_reset_form()
    9396    return render_to_response(template_name, {
    def password_reset_done(request, template_name='registration/password_reset_done  
    98101    return render_to_response(template_name, context_instance=RequestContext(request))
    99102
    100103def password_reset_confirm(request, uidb36=None, token=None, template_name='registration/password_reset_confirm.html',
    101                            token_generator=default_token_generator, set_password_form=SetPasswordForm):
     104                           token_generator=default_token_generator, set_password_form=SetPasswordForm,
     105                           post_reset_redirect=None):
    102106    """
    103107    View that checks the hash in a password reset link and presents a
    104108    form for entering a new password.
    105109    """
    106110    assert uidb36 is not None and token is not None # checked by URLconf
     111    if post_reset_redirect is None:
     112        post_reset_redirect = reverse('django.contrib.auth.views.password_reset_complete')
    107113    try:
    108114        uid_int = base36_to_int(uidb36)
    109115    except ValueError:
    def password_reset_confirm(request, uidb36=None, token=None, template_name='regi  
    118124            form = set_password_form(user, request.POST)
    119125            if form.is_valid():
    120126                form.save()
    121                 return HttpResponseRedirect(reverse('django.contrib.auth.views.password_reset_complete'))
     127                return HttpResponseRedirect(post_reset_redirect)
    122128        else:
    123129            form = set_password_form(None)
    124130    else:
    def password_reset_complete(request, template_name='registration/password_reset_  
    131137    return render_to_response(template_name, context_instance=RequestContext(request,
    132138                                                                             {'login_url': settings.LOGIN_URL}))
    133139
    134 def password_change(request, template_name='registration/password_change_form.html'):
     140def password_change(request, template_name='registration/password_change_form.html',
     141                    post_change_redirect=None):
     142    if post_save_redirect is None:
     143        post_save_redirect = reverse('django.contrib.auth.views.password_change_done')
    135144    if request.method == "POST":
    136145        form = PasswordChangeForm(request.user, request.POST)
    137146        if form.is_valid():
    138147            form.save()
    139             return HttpResponseRedirect(reverse('django.contrib.auth.views.password_change_done'))
     148            return HttpResponseRedirect(post_save_redirect)
    140149    else:
    141150        form = PasswordChangeForm(request.user)
    142151    return render_to_response(template_name, {
Back to Top