mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
add directory creation
This commit is contained in:
parent
e2268f9234
commit
617cc06125
@ -60,10 +60,8 @@ def corpus(corpus_id):
|
|||||||
@main.route('/corpora/<int:corpus_id>/delete')
|
@main.route('/corpora/<int:corpus_id>/delete')
|
||||||
@login_required
|
@login_required
|
||||||
def delete_corpus(corpus_id):
|
def delete_corpus(corpus_id):
|
||||||
delete_thread = threading.Thread(
|
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
||||||
target=background_delete_corpus,
|
delete_thread = threading.Thread(corpus.delete())
|
||||||
args=(current_app._get_current_object(), corpus_id)
|
|
||||||
)
|
|
||||||
delete_thread.start()
|
delete_thread.start()
|
||||||
flash('Corpus has been deleted!')
|
flash('Corpus has been deleted!')
|
||||||
return redirect(url_for('main.dashboard'))
|
return redirect(url_for('main.dashboard'))
|
||||||
@ -121,6 +119,16 @@ def dashboard():
|
|||||||
title=create_corpus_form.title.data)
|
title=create_corpus_form.title.data)
|
||||||
db.session.add(corpus)
|
db.session.add(corpus)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
|
||||||
|
str(corpus.user_id),
|
||||||
|
'corpora',
|
||||||
|
str(corpus.id))
|
||||||
|
try:
|
||||||
|
os.makedirs(dir)
|
||||||
|
except OSError:
|
||||||
|
flash('OSError!')
|
||||||
|
db.session.remove(corpus)
|
||||||
|
db.session.commit()
|
||||||
flash('Corpus created!')
|
flash('Corpus created!')
|
||||||
return redirect(url_for('main.dashboard'))
|
return redirect(url_for('main.dashboard'))
|
||||||
return render_template('main/dashboard.html.j2',
|
return render_template('main/dashboard.html.j2',
|
||||||
|
Loading…
Reference in New Issue
Block a user