diff --git a/app/main/views.py b/app/main/views.py index 7dcafa68..0d138b2d 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -60,10 +60,8 @@ def corpus(corpus_id): @main.route('/corpora//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',