From 775ddc601e1465b2505470078f4adf830cd0b530 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Fri, 25 Oct 2019 15:09:19 +0200 Subject: [PATCH] Code enhancement --- app/main/views.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/main/views.py b/app/main/views.py index 4d955a3f..eabc4bea 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -20,7 +20,8 @@ def index(): @login_required def corpus(corpus_id): corpus = Corpus.query.get_or_404(corpus_id) - if not (corpus.creator == current_user or current_user.is_administrator()): + if not (corpus.creator == current_user + or current_user.is_administrator()): abort(403) return render_template('main/corpora/corpus.html.j2', corpus=corpus, @@ -57,20 +58,16 @@ def corpus_analysis(corpus_id): @login_required def dashboard(): create_corpus_form = CreateCorpusForm() - if create_corpus_form.validate_on_submit(): - app = current_app._get_current_object() corpus = Corpus(creator=current_user._get_current_object(), description=create_corpus_form.description.data, title=create_corpus_form.title.data) db.session.add(corpus) db.session.commit() - - dir = os.path.join(app.config['OPAQUE_STORAGE_DIRECTORY'], + dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'], str(corpus.user_id), 'corpora', str(corpus.id)) - try: os.makedirs(dir) except OSError: @@ -89,7 +86,6 @@ def dashboard(): db.session.commit() flash('Corpus created!') return redirect(url_for('main.dashboard')) - return render_template('main/dashboard.html.j2', create_corpus_form=create_corpus_form, title='Dashboard')