Ticket #2375: email_template.2.patch

File email_template.2.patch, 2.3 KB (added by treborhudson@…, 18 years ago)

The first patch forgot the default email template in save() function

  • contrib/auth/views.py

     
    5050    "Redirects the user to the login page, passing the given 'next' page"
    5151    return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, next))
    5252
    53 def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html'):
     53def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html', email_template_name='registration/password_reset_email.html'):
    5454    new_data, errors = {}, {}
    5555    form = PasswordResetForm()
    5656    if request.POST:
     
    5858        errors = form.get_validation_errors(new_data)
    5959        if not errors:
    6060            if is_admin_site:
    61                 form.save(request.META['HTTP_HOST'])
     61                form.save(domain_override=request.META['HTTP_HOST'])
    6262            else:
    63                 form.save()
     63                form.save(email_template=email_template_name)
    6464            return HttpResponseRedirect('%sdone/' % request.path)
    6565    return render_to_response(template_name, {'form': forms.FormWrapper(form, new_data, errors)},
    6666        context_instance=RequestContext(request))
  • contrib/auth/forms.py

     
    6161        except User.DoesNotExist:
    6262            raise validators.ValidationError, "That e-mail address doesn't have an associated user acount. Are you sure you've registered?"
    6363
    64     def save(self, domain_override=None):
     64    def save(self, domain_override=None, email_template='registration/password_reset_email.html'):
    6565        "Calculates a new password randomly and sends it to the user"
    6666        from django.core.mail import send_mail
    6767        new_pass = User.objects.make_random_password()
     
    7373            domain = current_site.domain
    7474        else:
    7575            site_name = domain = domain_override
    76         t = loader.get_template('registration/password_reset_email.html')
     76        t = loader.get_template(email_template)
    7777        c = {
    7878            'new_password': new_pass,
    7979            'email': self.user_cache.email,
Back to Top