Browse Source

postkey: add "success" view

pull/1/head
Hidden Z 14 years ago
parent
commit
e191306c7e
  1. 1
      web/postkey/urls.py
  2. 10
      web/postkey/views.py

1
web/postkey/urls.py

@ -2,4 +2,5 @@ from django.conf.urls.defaults import *
urlpatterns = patterns('web.postkey.views', urlpatterns = patterns('web.postkey.views',
(r'^$', 'addkey'), (r'^$', 'addkey'),
(r'^success/', 'success'),
) )

10
web/postkey/views.py

@ -54,10 +54,16 @@ def addkey(request):
if request.method == 'POST': if request.method == 'POST':
form = AddForm(request.POST) form = AddForm(request.POST)
if form.is_valid(): if form.is_valid():
#form.save() form.save()
return HttpResponseRedirect('/postkey/success/') request.session['hostname'] = form.cleaned_data['name']
return HttpResponseRedirect('success')
else: else:
form = AddForm() form = AddForm()
return render_to_response('postkey.html', { return render_to_response('postkey.html', {
'form': form, 'form': form,
}, context_instance=RequestContext(request)) }, context_instance=RequestContext(request))
def success(request):
return render_to_response('success_submission.html', {
'hostname': request.session['hostname'],
})

Loading…
Cancel
Save