Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Converted django.views.registration.passwords to use load_and_render …

…-- it's less code

git-svn-id: http://code.djangoproject.com/svn/django/trunk@658 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 48f0820337f5673dbcd629f30a05968356a594e6 1 parent a6946da
Adrian Holovaty adrianholovaty authored
Showing with 8 additions and 18 deletions.
  1. +8 −18 django/views/registration/passwords.py
26 django/views/registration/passwords.py
View
@@ -1,8 +1,8 @@
from django.core import formfields, template_loader, validators
-from django.core.extensions import DjangoContext as Context
+from django.core.extensions import DjangoContext, load_and_render
from django.models.auth import users
from django.views.decorators.auth import login_required
-from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
+from django.utils.httpwrappers import HttpResponseRedirect
class PasswordResetForm(formfields.Manipulator):
"A form that lets a user request a password reset"
@@ -76,16 +76,11 @@ def password_reset(request, is_admin_site=False):
else:
form.save()
return HttpResponseRedirect('%sdone/' % request.path)
- t = template_loader.get_template('registration/password_reset_form')
- c = Context(request, {
- 'form': formfields.FormWrapper(form, new_data, errors),
- })
- return HttpResponse(t.render(c))
+ return load_and_render('registration/password_reset_form', {'form': formfields.FormWrapper(form, new_data, errors)},
+ context_instance=DjangoContext(request))
def password_reset_done(request):
- t = template_loader.get_template('registration/password_reset_done')
- c = Context(request, {})
- return HttpResponse(t.render(c))
+ return load_and_render('registration/password_reset_done', context_instance=DjangoContext(request))
def password_change(request):
new_data, errors = {}, {}
@@ -96,14 +91,9 @@ def password_change(request):
if not errors:
form.save(new_data)
return HttpResponseRedirect('%sdone/' % request.path)
- t = template_loader.get_template('registration/password_change_form')
- c = Context(request, {
- 'form': formfields.FormWrapper(form, new_data, errors),
- })
- return HttpResponse(t.render(c))
+ return load_and_render('registration/password_change_form', {'form': formfields.FormWrapper(form, new_data, errors)},
+ context_instance=DjangoContext(request))
password_change = login_required(password_change)
def password_change_done(request):
- t = template_loader.get_template('registration/password_change_done')
- c = Context(request, {})
- return HttpResponse(t.render(c))
+ return load_and_render('registration/password_change_done', context_instance=DjangoContext(request))
Please sign in to comment.
Something went wrong with that request. Please try again.