diff --git a/django/contrib/admin/templates/registration/password_reset_subject.txt b/django/contrib/admin/templates/registration/password_reset_subject.txt
new file mode 100644
-
|
+
|
|
| 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
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
a
|
b
|
|
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.txt', |
| 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 | """ |
… |
… |
|
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, |
… |
… |
|
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
a
|
b
|
|
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.txt b/django/contrib/auth/tests/templates/registration/password_reset_subject.txt
new file mode 100644
-
|
+
|
|
| 1 | {% load i18n %}{% autoescape off %} |
| 2 | {% blocktrans %}Custom password reset on {{ site_name }}{% endblocktrans %} |
| 3 | {% endautoescape %} |
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
a
|
b
|
|
128 | 128 | post_reset_redirect=None, |
129 | 129 | from_email=None, |
130 | 130 | current_app=None, |
131 | | extra_context=None): |
| 131 | extra_context=None, |
| 132 | subject_template_name='registration/password_reset_subject.txt'): |
132 | 133 | if post_reset_redirect is None: |
133 | 134 | post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done') |
134 | 135 | if request.method == "POST": |
… |
… |
|
140 | 141 | 'from_email': from_email, |
141 | 142 | 'email_template_name': email_template_name, |
142 | 143 | 'request': request, |
| 144 | 'subject_template_name': subject_template_name, |
143 | 145 | } |
144 | 146 | if is_admin_site: |
145 | 147 | opts = dict(opts, domain_override=request.META['HTTP_HOST']) |
diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
a
|
b
|
|
356 | 356 | if domain == 'djangojs': |
357 | 357 | extensions = handle_extensions(extensions or ['js']) |
358 | 358 | else: |
359 | | extensions = handle_extensions(extensions or ['html']) |
| 359 | extensions = handle_extensions(extensions or ['html', 'txt']) |
360 | 360 | |
361 | 361 | if verbosity > 1: |
362 | 362 | sys.stdout.write('examining files with the extensions: %s\n' |