1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-02-02 01:44:40 +00:00

Add initial urls.py and views.py

This commit is contained in:
Hidden Z 2010-10-06 19:02:08 +00:00
parent 53e564265d
commit 7434e4c8c8
2 changed files with 28 additions and 0 deletions

5
web/postkey/urls.py Normal file
View File

@ -0,0 +1,5 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('web.postkey.views',
(r'^$', 'index'),
)

23
web/postkey/views.py Normal file
View File

@ -0,0 +1,23 @@
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.forms import ModelForm
from django.template import RequestContext
from web.postkey.models import i2phost
class AddForm(ModelForm):
class Meta:
model = i2phost
fields = ('name', 'b64hash')
def index(request):
if request.method == 'POST':
form = AddForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/postkey/success/')
else:
form = AddForm()
return render_to_response('postkey.html', {
'form': form,
}, context_instance=RequestContext(request))