Ticket #5298: fix-extra_context.diff
File fix-extra_context.diff, 3.9 KB (added by , 17 years ago) |
---|
-
django/contrib/auth/views.py
9 9 from django.contrib.auth import REDIRECT_FIELD_NAME 10 10 from django.utils.translation import ugettext as _ 11 11 12 def login(request, template_name='registration/login.html' ):12 def login(request, template_name='registration/login.html', extra_context={}): 13 13 "Displays the login form and handles the login action." 14 14 manipulator = AuthenticationForm(request) 15 15 redirect_to = request.REQUEST.get(REDIRECT_FIELD_NAME, '') … … 37 37 'form': oldforms.FormWrapper(manipulator, request.POST, errors), 38 38 REDIRECT_FIELD_NAME: redirect_to, 39 39 'site_name': current_site.name, 40 }, context_instance=RequestContext(request ))40 }, context_instance=RequestContext(request, extra_context)) 41 41 42 def logout(request, next_page=None, template_name='registration/logged_out.html' ):42 def logout(request, next_page=None, template_name='registration/logged_out.html', extra_context={}): 43 43 "Logs out the user and displays 'You are logged out' message." 44 44 from django.contrib.auth import logout 45 45 logout(request) 46 46 if next_page is None: 47 return render_to_response(template_name, {'title': _('Logged out')}, context_instance=RequestContext(request ))47 return render_to_response(template_name, {'title': _('Logged out')}, context_instance=RequestContext(request, extra_context)) 48 48 else: 49 49 # Redirect to this page until the session has been cleared. 50 50 return HttpResponseRedirect(next_page or request.path) … … 64 64 return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, next)) 65 65 66 66 def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html', 67 email_template_name='registration/password_reset_email.html' ):67 email_template_name='registration/password_reset_email.html', extra_context={}): 68 68 new_data, errors = {}, {} 69 69 form = PasswordResetForm() 70 70 if request.POST: … … 77 77 form.save(email_template_name=email_template_name) 78 78 return HttpResponseRedirect('%sdone/' % request.path) 79 79 return render_to_response(template_name, {'form': oldforms.FormWrapper(form, new_data, errors)}, 80 context_instance=RequestContext(request ))80 context_instance=RequestContext(request, extra_context)) 81 81 82 def password_reset_done(request, template_name='registration/password_reset_done.html' ):83 return render_to_response(template_name, context_instance=RequestContext(request ))82 def password_reset_done(request, template_name='registration/password_reset_done.html', extra_context={}): 83 return render_to_response(template_name, context_instance=RequestContext(request, extra_context)) 84 84 85 def password_change(request, template_name='registration/password_change_form.html' ):85 def password_change(request, template_name='registration/password_change_form.html', extra_context={}): 86 86 new_data, errors = {}, {} 87 87 form = PasswordChangeForm(request.user) 88 88 if request.POST: … … 92 92 form.save(new_data) 93 93 return HttpResponseRedirect('%sdone/' % request.path) 94 94 return render_to_response(template_name, {'form': oldforms.FormWrapper(form, new_data, errors)}, 95 context_instance=RequestContext(request ))95 context_instance=RequestContext(request, extra_context)) 96 96 password_change = login_required(password_change) 97 97 98 def password_change_done(request, template_name='registration/password_change_done.html' ):99 return render_to_response(template_name, context_instance=RequestContext(request ))98 def password_change_done(request, template_name='registration/password_change_done.html', extra_context={}): 99 return render_to_response(template_name, context_instance=RequestContext(request, extra_context))