add directory creation

This commit is contained in:
Patrick Jentsch 2019-10-30 09:20:57 +01:00
parent e2268f9234
commit 617cc06125

View File

@ -60,10 +60,8 @@ def corpus(corpus_id):
@main.route('/corpora/<int:corpus_id>/delete')
@login_required
def delete_corpus(corpus_id):
delete_thread = threading.Thread(
target=background_delete_corpus,
args=(current_app._get_current_object(), corpus_id)
)
corpus = Corpus.query.filter_by(id=corpus_id).first()
delete_thread = threading.Thread(corpus.delete())
delete_thread.start()
flash('Corpus has been deleted!')
return redirect(url_for('main.dashboard'))
@ -121,6 +119,16 @@ def dashboard():
title=create_corpus_form.title.data)
db.session.add(corpus)
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!')
return redirect(url_for('main.dashboard'))
return render_template('main/dashboard.html.j2',