mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-02-02 01:44:40 +00:00
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/
This commit is contained in:
parent
8e2ac32684
commit
34d3243fcc
@ -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('/')
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user