diff options
Diffstat (limited to 'app/main.py')
-rw-r--r-- | app/main.py | 11 |
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 |