mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 02:24:20 +00:00
Code enhancement
This commit is contained in:
parent
0a6bc055a0
commit
775ddc601e
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user