mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-12 09:00:40 +00:00
restructure corpus delete method
This commit is contained in:
@ -57,6 +57,18 @@ def corpus(corpus_id):
|
||||
title='Corpus')
|
||||
|
||||
|
||||
@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)
|
||||
)
|
||||
delete_thread.start()
|
||||
flash('Corpus has been deleted!')
|
||||
return redirect(url_for('main.dashboard'))
|
||||
|
||||
|
||||
@main.route('/corpora/<int:corpus_id>/download')
|
||||
@login_required
|
||||
def corpus_download(corpus_id):
|
||||
@ -100,27 +112,7 @@ 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!')
|
||||
else:
|
||||
for file in create_corpus_form.files.data:
|
||||
filename = secure_filename(file.filename)
|
||||
file.save(os.path.join(dir, filename))
|
||||
file_dir = os.path.join(str(corpus.user_id),
|
||||
'corpora',
|
||||
str(corpus.id))
|
||||
corpus_file = CorpusFile(filename=filename,
|
||||
corpus_id=corpus.id,
|
||||
dir=file_dir)
|
||||
db.session.add(corpus_file)
|
||||
db.session.commit()
|
||||
flash('Corpus created!')
|
||||
flash('Corpus created!')
|
||||
return redirect(url_for('main.dashboard'))
|
||||
return render_template('main/dashboard.html.j2',
|
||||
create_corpus_form=create_corpus_form,
|
||||
@ -169,15 +161,3 @@ def delete_job(job_id):
|
||||
delete_thread.start()
|
||||
flash('Job has been deleted!')
|
||||
return redirect(url_for('main.dashboard'))
|
||||
|
||||
|
||||
@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)
|
||||
)
|
||||
delete_thread.start()
|
||||
flash('Corpus has been deleted!')
|
||||
return redirect(url_for('main.dashboard'))
|
||||
|
Reference in New Issue
Block a user