summaryrefslogtreecommitdiffstats
path: root/app/main.py
diff options
context:
space:
mode:
authorNico Geyso <nico.geyso@fu-berlin.de>2014-12-07 18:25:29 +0100
committerNico Geyso <nico.geyso@fu-berlin.de>2014-12-07 18:25:29 +0100
commit79788b3590aba6384611a2c29012bbd821c290ee (patch)
tree183dcc14c9bc5394c32bb664d1361d783860ceb0 /app/main.py
parent4ea12c4b97fc7775ab5ae3cb4607f715b880aede (diff)
downloadklausuren-79788b3590aba6384611a2c29012bbd821c290ee.tar.gz
klausuren-79788b3590aba6384611a2c29012bbd821c290ee.tar.bz2
klausuren-79788b3590aba6384611a2c29012bbd821c290ee.zip
Added write functionality to Storage backend
Diffstat (limited to 'app/main.py')
-rw-r--r--app/main.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/main.py b/app/main.py
index cdc8d0b..cf6a99e 100644
--- a/app/main.py
+++ b/app/main.py
@@ -6,8 +6,10 @@ from flask import Blueprint, render_template, request, flash, redirect,\
from werkzeug import secure_filename
from .forms import UploadForm
+
main = Blueprint('main', __name__)
+
@main.route('/<study>/upload/', methods=['GET', 'POST'])
@main.route('/<study>/upload/<module>', methods=['GET', 'POST'])
def upload(study, module = None):
@@ -31,16 +33,15 @@ def upload(study, module = None):
year = form.year.data
filename = secure_filename(form.exam.data.filename)
- path = os.path.join(module,year,filename)
-
try:
- oid = g.studies[study].add_file(form.exam.data.stream.getvalue(), path)
+ data = form.exam.data.stream.getvalue()
except:
- oid = g.studies[study].add_file(form.exam.data.stream.read(), path)
+ data = form.exam.data.stream.read()
+ g.studies[study].add_file(module, year, filename, data)
flash("Datei %s gespeichert." % filename)
- return redirect(url_for('study_index', study = study, module = module))
+ return redirect(url_for('.study_index', study = study, module = module))
try: form.module.data = [k for (k,v) in form.module.choices if v == module][0]
except: pass