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:
parent
53e564265d
commit
7434e4c8c8
5
web/postkey/urls.py
Normal file
5
web/postkey/urls.py
Normal 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
23
web/postkey/views.py
Normal 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))
|
Loading…
x
Reference in New Issue
Block a user