Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #2375 -- Changed password_reset auth view to make e-mail templa…

…te name variable. Thanks, treborhudson@gmail.com

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3462 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2a0af00524fc16f3f223b8117268e9ffcf41e06c 1 parent c7fa1fa
Adrian Holovaty authored July 27, 2006
4  django/contrib/auth/forms.py
@@ -61,7 +61,7 @@ def isValidUserEmail(self, new_data, all_data):
61 61
         except User.DoesNotExist:
62 62
             raise validators.ValidationError, "That e-mail address doesn't have an associated user acount. Are you sure you've registered?"
63 63
 
64  
-    def save(self, domain_override=None):
  64
+    def save(self, domain_override=None, email_template_name='registration/password_reset_email.html'):
65 65
         "Calculates a new password randomly and sends it to the user"
66 66
         from django.core.mail import send_mail
67 67
         new_pass = User.objects.make_random_password()
@@ -73,7 +73,7 @@ def save(self, domain_override=None):
73 73
             domain = current_site.domain
74 74
         else:
75 75
             site_name = domain = domain_override
76  
-        t = loader.get_template('registration/password_reset_email.html')
  76
+        t = loader.get_template(email_template_name)
77 77
         c = {
78 78
             'new_password': new_pass,
79 79
             'email': self.user_cache.email,
7  django/contrib/auth/views.py
@@ -49,7 +49,8 @@ def redirect_to_login(next, login_url=LOGIN_URL):
49 49
     "Redirects the user to the login page, passing the given 'next' page"
50 50
     return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, next))
51 51
 
52  
-def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html'):
  52
+def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html',
  53
+        email_template_name='registration/password_reset_email.html'):
53 54
     new_data, errors = {}, {}
54 55
     form = PasswordResetForm()
55 56
     if request.POST:
@@ -57,9 +58,9 @@ def password_reset(request, is_admin_site=False, template_name='registration/pas
57 58
         errors = form.get_validation_errors(new_data)
58 59
         if not errors:
59 60
             if is_admin_site:
60  
-                form.save(request.META['HTTP_HOST'])
  61
+                form.save(domain_override=request.META['HTTP_HOST'])
61 62
             else:
62  
-                form.save()
  63
+                form.save(email_template_name=email_template_name)
63 64
             return HttpResponseRedirect('%sdone/' % request.path)
64 65
     return render_to_response(template_name, {'form': forms.FormWrapper(form, new_data, errors)},
65 66
         context_instance=RequestContext(request))

0 notes on commit 2a0af00

Please sign in to comment.
Something went wrong with that request. Please try again.