Browse Source

Use RequestContext in all render_to_response()

We have {% csrf_token %} in a templates, but the context in
render_to_response() does not provide the value.

https://docs.djangoproject.com/en/1.5/ref/contrib/csrf/
pull/1/head
Hidden Z 11 years ago
parent
commit
34d3243fcc
  1. 7
      pyi2phosts/jump/views.py
  2. 4
      pyi2phosts/postkey/views.py

7
pyi2phosts/jump/views.py

@ -4,6 +4,7 @@ from django.shortcuts import render_to_response
from django.shortcuts import redirect from django.shortcuts import redirect
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.conf import settings from django.conf import settings
from django.template import RequestContext
from pyi2phosts.postkey.models import i2phost from pyi2phosts.postkey.models import i2phost
from pyi2phosts.lib.validation import validate_hostname from pyi2phosts.lib.validation import validate_hostname
@ -16,13 +17,13 @@ def jumper(request, host):
return render_to_response('jump-error.html', { return render_to_response('jump-error.html', {
'title': settings.SITE_NAME, 'title': settings.SITE_NAME,
'error': e, 'error': e,
}) }, context_instance=RequestContext(request))
try: try:
h = i2phost.objects.get(name=hostname) h = i2phost.objects.get(name=hostname)
except i2phost.DoesNotExist: except i2phost.DoesNotExist:
return render_to_response('jump-unknown.html', { return render_to_response('jump-unknown.html', {
'title': settings.SITE_NAME, 'title': settings.SITE_NAME,
}) }, context_instance=RequestContext(request))
if h.activated == True: if h.activated == True:
key = h.b64hash key = h.b64hash
else: else:
@ -47,7 +48,7 @@ def jumper(request, host):
return render_to_response('jump.html', { return render_to_response('jump.html', {
'title': settings.SITE_NAME, 'title': settings.SITE_NAME,
'url': url, 'url': url,
}) }, context_instance=RequestContext(request))
def index(request): def index(request):
return redirect('/') return redirect('/')

4
pyi2phosts/postkey/views.py

@ -106,7 +106,7 @@ def success(request):
return render_to_response('success_submission.html', { return render_to_response('success_submission.html', {
'title': settings.SITE_NAME, 'title': settings.SITE_NAME,
'hostname': hn, 'hostname': hn,
}) }, context_instance=RequestContext(request))
else: else:
return redirect('/') return redirect('/')
@ -136,7 +136,7 @@ def subdomain(request):
return render_to_response('subdomain_http_verify_failure.html', { return render_to_response('subdomain_http_verify_failure.html', {
'title': settings.SITE_NAME, 'title': settings.SITE_NAME,
'code': e.code, 'code': e.code,
}) }, context_instance=RequestContext(request))
else: else:
log.debug('subdomain verification success, saving host') log.debug('subdomain verification success, saving host')
s = save_host(request) s = save_host(request)

Loading…
Cancel
Save