Ticket #12202: reset_password.diff

File reset_password.diff, 2.2 KB (added by Austin Gabel, 15 years ago)

Attached the wrong patch before. I will be bringing up this patch to django-dev shortly.

  • new file django/contrib/admin/templates/registration/password_reset_subject.html

    diff --git a/django/contrib/admin/templates/registration/password_reset_subject.html b/django/contrib/admin/templates/registration/password_reset_subject.html
    new file mode 100644
    index 0000000..45a354b
    - +  
     1{% load i18n %}{% autoescape off %}
     2{% blocktrans %}Password reset on {{ site_name }}{% endblocktrans %}
     3{% endautoescape %}
     4 No newline at end of file
  • django/contrib/auth/forms.py

    diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
    index 55e770e..0d8c2c0 100644
    a b class PasswordResetForm(forms.Form):  
    109109            raise forms.ValidationError(_("That e-mail address doesn't have an associated user account. Are you sure you've registered?"))
    110110        return email
    111111
    112     def save(self, domain_override=None, email_template_name='registration/password_reset_email.html',
     112    def save(self, domain_override=None,
     113             subject_template_name='registration/password_reset_subject.html',
     114             email_template_name='registration/password_reset_email.html',
    113115             use_https=False, token_generator=default_token_generator):
    114116        """
    115117        Generates a one-use only link for resetting password and sends to the user
    class PasswordResetForm(forms.Form):  
    122124                domain = current_site.domain
    123125            else:
    124126                site_name = domain = domain_override
    125             t = loader.get_template(email_template_name)
    126127            c = {
    127128                'email': user.email,
    128129                'domain': domain,
    class PasswordResetForm(forms.Form):  
    132133                'token': token_generator.make_token(user),
    133134                'protocol': use_https and 'https' or 'http',
    134135            }
    135             send_mail(_("Password reset on %s") % site_name,
    136                 t.render(Context(c)), None, [user.email])
     136            subject = loader.render_to_string(subject_template_name, c)
     137            subject = ''.join(subject.splitlines())
     138            email = loader.render_to_string(email_template_name, c)
     139            send_mail(subject, email, None, [user.email])
    137140
    138141class SetPasswordForm(forms.Form):
    139142    """
Back to Top