Ticket #12202: 12202.1.diff

File 12202.1.diff, 5.8 KB (added by Ramiro Morales, 13 years ago)

Claude patch plus update of makmessages command and reset_password() view

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

    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
  • django/contrib/auth/fixtures/authtestdata.json

    diff --git a/django/contrib/auth/fixtures/authtestdata.json b/django/contrib/auth/fixtures/authtestdata.json
    a b  
    3131            "groups": [],
    3232            "user_permissions": [],
    3333            "password": "sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161",
    34             "email": "testclient@example.com",
     34            "email": "testclient2@example.com",
    3535            "date_joined": "2006-12-17 07:03:31"
    3636        }
    3737    },
  • django/contrib/auth/forms.py

    diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
    a b  
    117117            raise forms.ValidationError(_("That e-mail address doesn't have an associated user account. Are you sure you've registered?"))
    118118        return email
    119119
    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):
    122125        """
    123126        Generates a one-use only link for resetting password and sends to the user
    124127        """
     
    130133                domain = current_site.domain
    131134            else:
    132135                site_name = domain = domain_override
    133             t = loader.get_template(email_template_name)
    134136            c = {
    135137                'email': user.email,
    136138                'domain': domain,
     
    140142                'token': token_generator.make_token(user),
    141143                'protocol': use_https and 'https' or 'http',
    142144            }
    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])
    145149
    146150class SetPasswordForm(forms.Form):
    147151    """
  • django/contrib/auth/tests/forms.py

    diff --git a/django/contrib/auth/tests/forms.py b/django/contrib/auth/tests/forms.py
    a b  
    242242        self.assertTrue(form.is_valid())
    243243        self.assertEqual(form.cleaned_data['email'], u'jsmith3@example.com')
    244244
     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
    245262
    246263    def test_bug_5605(self):
    247264        # bug #5605, preserve the case of the user name (before the @ in the
  • new file django/contrib/auth/tests/templates/registration/password_reset_subject.txt

    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 %}
  • django/contrib/auth/views.py

    diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
    a b  
    128128                   post_reset_redirect=None,
    129129                   from_email=None,
    130130                   current_app=None,
    131                    extra_context=None):
     131                   extra_context=None,
     132                   subject_template_name='registration/password_reset_subject.txt'):
    132133    if post_reset_redirect is None:
    133134        post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done')
    134135    if request.method == "POST":
     
    140141                'from_email': from_email,
    141142                'email_template_name': email_template_name,
    142143                'request': request,
     144                'subject_template_name': subject_template_name,
    143145            }
    144146            if is_admin_site:
    145147                opts = dict(opts, domain_override=request.META['HTTP_HOST'])
  • django/core/management/commands/makemessages.py

    diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
    a b  
    356356        if domain == 'djangojs':
    357357            extensions = handle_extensions(extensions or ['js'])
    358358        else:
    359             extensions = handle_extensions(extensions or ['html'])
     359            extensions = handle_extensions(extensions or ['html', 'txt'])
    360360
    361361        if verbosity > 1:
    362362            sys.stdout.write('examining files with the extensions: %s\n'
Back to Top