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
This commit is contained in:
parent
a6946dac54
commit
48f0820337
|
@ -1,8 +1,8 @@
|
||||||
from django.core import formfields, template_loader, validators
|
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.models.auth import users
|
||||||
from django.views.decorators.auth import login_required
|
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):
|
class PasswordResetForm(formfields.Manipulator):
|
||||||
"A form that lets a user request a password reset"
|
"A form that lets a user request a password reset"
|
||||||
|
@ -76,16 +76,11 @@ def password_reset(request, is_admin_site=False):
|
||||||
else:
|
else:
|
||||||
form.save()
|
form.save()
|
||||||
return HttpResponseRedirect('%sdone/' % request.path)
|
return HttpResponseRedirect('%sdone/' % request.path)
|
||||||
t = template_loader.get_template('registration/password_reset_form')
|
return load_and_render('registration/password_reset_form', {'form': formfields.FormWrapper(form, new_data, errors)},
|
||||||
c = Context(request, {
|
context_instance=DjangoContext(request))
|
||||||
'form': formfields.FormWrapper(form, new_data, errors),
|
|
||||||
})
|
|
||||||
return HttpResponse(t.render(c))
|
|
||||||
|
|
||||||
def password_reset_done(request):
|
def password_reset_done(request):
|
||||||
t = template_loader.get_template('registration/password_reset_done')
|
return load_and_render('registration/password_reset_done', context_instance=DjangoContext(request))
|
||||||
c = Context(request, {})
|
|
||||||
return HttpResponse(t.render(c))
|
|
||||||
|
|
||||||
def password_change(request):
|
def password_change(request):
|
||||||
new_data, errors = {}, {}
|
new_data, errors = {}, {}
|
||||||
|
@ -96,14 +91,9 @@ def password_change(request):
|
||||||
if not errors:
|
if not errors:
|
||||||
form.save(new_data)
|
form.save(new_data)
|
||||||
return HttpResponseRedirect('%sdone/' % request.path)
|
return HttpResponseRedirect('%sdone/' % request.path)
|
||||||
t = template_loader.get_template('registration/password_change_form')
|
return load_and_render('registration/password_change_form', {'form': formfields.FormWrapper(form, new_data, errors)},
|
||||||
c = Context(request, {
|
context_instance=DjangoContext(request))
|
||||||
'form': formfields.FormWrapper(form, new_data, errors),
|
|
||||||
})
|
|
||||||
return HttpResponse(t.render(c))
|
|
||||||
password_change = login_required(password_change)
|
password_change = login_required(password_change)
|
||||||
|
|
||||||
def password_change_done(request):
|
def password_change_done(request):
|
||||||
t = template_loader.get_template('registration/password_change_done')
|
return load_and_render('registration/password_change_done', context_instance=DjangoContext(request))
|
||||||
c = Context(request, {})
|
|
||||||
return HttpResponse(t.render(c))
|
|
||||||
|
|
Loading…
Reference in New Issue