Starting with the test submit view using wtforms
[mediagoblin.git] / mediagoblin / views.py
1 from webob import Response, exc
2 import wtforms
3
4 def root_view(request):
5 return Response("This is the root")
6
7
8 class ImageSubmitForm(wtforms.Form):
9 title = wtforms.TextField(
10 'Title',
11 [wtforms.validators.Length(min=1, max=500)])
12 description = wtforms.TextAreaField('Description of this work')
13 file = wtforms.FileField('File')
14
15
16 def submit_test(request):
17 image_form = ImageSubmitForm(request.POST)
18 if request.method == 'POST' and image_form.validate():
19 # create entry and save in database
20
21 # save file to disk
22 ## TODO
23
24 # resize if necessary
25 ## Hm. This should be done on a separate view?
26
27 # redirect
28 pass
29
30 # render
31 template = request.template_env.get_template(
32 'mediagoblin/test_submit.html')
33 return Response(
34 template.render(
35 {'request': request,
36 'image_form': image_form}))