diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-03-27 17:32:27 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-03-27 17:32:27 -0500 |
commit | ef7cdac5b97374418ef94891981539ea07216fe4 (patch) | |
tree | 97fe572d5b5184b3b2f618d85ce267b0bf4df221 /mediagoblin/views.py | |
parent | 6f86cfe95c9de40a1e0baaf2b19f3377a1db5f32 (diff) | |
download | mediagoblin-ef7cdac5b97374418ef94891981539ea07216fe4.tar.lz mediagoblin-ef7cdac5b97374418ef94891981539ea07216fe4.tar.xz mediagoblin-ef7cdac5b97374418ef94891981539ea07216fe4.zip |
A testing submit view that doesn't work but is getting closer to working.
Diffstat (limited to 'mediagoblin/views.py')
-rw-r--r-- | mediagoblin/views.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/mediagoblin/views.py b/mediagoblin/views.py index 116237b7..eca40203 100644 --- a/mediagoblin/views.py +++ b/mediagoblin/views.py @@ -3,6 +3,8 @@ import datetime from webob import Response, exc import wtforms +from mediagoblin import models + def root_view(request): return Response("This is the root") @@ -19,13 +21,21 @@ def submit_test(request): image_form = ImageSubmitForm(request.POST) if request.method == 'POST' and image_form.validate(): # create entry and save in database - work_id = request.app.db.works.insert( - {'title': image_form.title.data, - 'created': datetime.datetime.now(), - 'description': image_form.description.data}) + + entry = request.db.MediaEntry() + entry['title'] = request.POST['title'] + entry['description'] = request.POST.get(['description'])o + entry['media_type'] = u'image' + + # TODO this does NOT look save, we should clean the filename somenow? + entry['file_store'] = request.POST['file'].filename + + entry.save(validate=True) # save file to disk ## TODO + #open('/tmp/read_file.png', 'wb').write(request.POST['file'].file.read()) + # resize if necessary ## Hm. This should be done on a separate view? @@ -33,6 +43,8 @@ def submit_test(request): # redirect pass + + # render template = request.template_env.get_template( 'mediagoblin/test_submit.html') |