summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-07-27 17:48:35 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-07-27 17:48:35 +0000
commit2a0af00524fc16f3f223b8117268e9ffcf41e06c (patch)
tree83abbb2d24bbf1f03af91bf850902df5a6010fc1
parentc7fa1fa56f97eaeedbe4ecff9510243452091168 (diff)
downloaddjango-2a0af00524fc16f3f223b8117268e9ffcf41e06c.tar.gz
Fixed #2375 -- Changed password_reset auth view to make e-mail template name variable. Thanks, treborhudson@gmail.com
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3462 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/auth/forms.py4
-rw-r--r--django/contrib/auth/views.py7
2 files changed, 6 insertions, 5 deletions
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index ef81268e2a..8bd9fa44c4 100644
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -61,7 +61,7 @@ class PasswordResetForm(forms.Manipulator):
except User.DoesNotExist:
raise validators.ValidationError, "That e-mail address doesn't have an associated user acount. Are you sure you've registered?"
- def save(self, domain_override=None):
+ def save(self, domain_override=None, email_template_name='registration/password_reset_email.html'):
"Calculates a new password randomly and sends it to the user"
from django.core.mail import send_mail
new_pass = User.objects.make_random_password()
@@ -73,7 +73,7 @@ class PasswordResetForm(forms.Manipulator):
domain = current_site.domain
else:
site_name = domain = domain_override
- t = loader.get_template('registration/password_reset_email.html')
+ t = loader.get_template(email_template_name)
c = {
'new_password': new_pass,
'email': self.user_cache.email,
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index 428efe6239..6882755787 100644
--- a/django/contrib/auth/views.py
+++ b/django/contrib/auth/views.py
@@ -49,7 +49,8 @@ def redirect_to_login(next, login_url=LOGIN_URL):
"Redirects the user to the login page, passing the given 'next' page"
return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, next))
-def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html'):
+def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html',
+ email_template_name='registration/password_reset_email.html'):
new_data, errors = {}, {}
form = PasswordResetForm()
if request.POST:
@@ -57,9 +58,9 @@ def password_reset(request, is_admin_site=False, template_name='registration/pas
errors = form.get_validation_errors(new_data)
if not errors:
if is_admin_site:
- form.save(request.META['HTTP_HOST'])
+ form.save(domain_override=request.META['HTTP_HOST'])
else:
- form.save()
+ form.save(email_template_name=email_template_name)
return HttpResponseRedirect('%sdone/' % request.path)
return render_to_response(template_name, {'form': forms.FormWrapper(form, new_data, errors)},
context_instance=RequestContext(request))