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 |
diff --git a/django/contrib/auth/fixtures/authtestdata.json b/django/contrib/auth/fixtures/authtestdata.json
index e0bdc24..c286743 100644
a
|
b
|
|
31 | 31 | "groups": [], |
32 | 32 | "user_permissions": [], |
33 | 33 | "password": "sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161", |
34 | | "email": "testclient@example.com", |
| 34 | "email": "testclient2@example.com", |
35 | 35 | "date_joined": "2006-12-17 07:03:31" |
36 | 36 | } |
37 | 37 | }, |
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index 7473279..d692086 100644
a
|
b
|
class PasswordResetForm(forms.Form):
|
117 | 117 | raise forms.ValidationError(_("That e-mail address doesn't have an associated user account. Are you sure you've registered?")) |
118 | 118 | return email |
119 | 119 | |
120 | | def save(self, domain_override=None, email_template_name='registration/password_reset_email.html', |
121 | | use_https=False, token_generator=default_token_generator, from_email=None, request=None): |
| 120 | def save(self, domain_override=None, |
| 121 | subject_template_name='registration/password_reset_subject.html', |
| 122 | email_template_name='registration/password_reset_email.html', |
| 123 | use_https=False, token_generator=default_token_generator, |
| 124 | from_email=None, request=None): |
122 | 125 | """ |
123 | 126 | Generates a one-use only link for resetting password and sends to the user |
124 | 127 | """ |
… |
… |
class PasswordResetForm(forms.Form):
|
130 | 133 | domain = current_site.domain |
131 | 134 | else: |
132 | 135 | site_name = domain = domain_override |
133 | | t = loader.get_template(email_template_name) |
134 | 136 | c = { |
135 | 137 | 'email': user.email, |
136 | 138 | 'domain': domain, |
… |
… |
class PasswordResetForm(forms.Form):
|
140 | 142 | 'token': token_generator.make_token(user), |
141 | 143 | 'protocol': use_https and 'https' or 'http', |
142 | 144 | } |
143 | | send_mail(_("Password reset on %s") % site_name, |
144 | | t.render(Context(c)), from_email, [user.email]) |
| 145 | subject = loader.render_to_string(subject_template_name, c) |
| 146 | subject = ''.join(subject.splitlines()) |
| 147 | email = loader.render_to_string(email_template_name, c) |
| 148 | send_mail(subject, email, from_email, [user.email]) |
145 | 149 | |
146 | 150 | class SetPasswordForm(forms.Form): |
147 | 151 | """ |
diff --git a/django/contrib/auth/tests/forms.py b/django/contrib/auth/tests/forms.py
index 5aa49e0..993c12f 100644
a
|
b
|
class PasswordResetFormTest(TestCase):
|
242 | 242 | self.assertTrue(form.is_valid()) |
243 | 243 | self.assertEqual(form.cleaned_data['email'], u'jsmith3@example.com') |
244 | 244 | |
| 245 | def test_custom_email_subject(self): |
| 246 | import os |
| 247 | from django.conf import settings |
| 248 | from django.core import mail |
| 249 | |
| 250 | old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS |
| 251 | settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),) |
| 252 | data = {'email': 'testclient@example.com'} |
| 253 | form = PasswordResetForm(data) |
| 254 | try: |
| 255 | self.assertTrue(form.is_valid()) |
| 256 | form.save() |
| 257 | |
| 258 | self.assertEqual(len(mail.outbox), 1) |
| 259 | self.assertEqual(mail.outbox[0].subject, u'Custom password reset on example.com') |
| 260 | finally: |
| 261 | settings.TEMPLATE_DIRS = old_TEMPLATE_DIRS |
245 | 262 | |
246 | 263 | def test_bug_5605(self): |
247 | 264 | # bug #5605, preserve the case of the user name (before the @ in the |
diff --git a/django/contrib/auth/tests/templates/registration/password_reset_subject.html b/django/contrib/auth/tests/templates/registration/password_reset_subject.html
new file mode 100644
index 0000000..f0d0eac
-
|
+
|
|
| 1 | {% load i18n %}{% autoescape off %} |
| 2 | {% blocktrans %}Custom password reset on {{ site_name }}{% endblocktrans %} |
| 3 | {% endautoescape %} |