From 0a8f6a5a44f42e8e88e992e831fb4cdeaeb72119 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Tue, 29 Oct 2019 13:56:32 +0100
Subject: [PATCH 2/3] Fix file save path
---
app/main/views.py | 2 +-
app/templates/main/corpora/corpus.html.j2 | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/main/views.py b/app/main/views.py
index b5b71985..362332bc 100644
--- a/app/main/views.py
+++ b/app/main/views.py
@@ -33,7 +33,7 @@ def corpus(corpus_id):
return redirect(url_for('main.corpus', corpus_id=corpus_id))
# Gather information to create new corpus file database entry
author = add_corpus_file_form.author.data
- dir = os.path.join(str(corpus.user_id), 'jobs', str(corpus.id))
+ dir = os.path.join(str(corpus.user_id), 'corpora', str(corpus.id))
file = add_corpus_file_form.file.data
publishing_year = add_corpus_file_form.publishing_year.data
title = add_corpus_file_form.title.data
diff --git a/app/templates/main/corpora/corpus.html.j2 b/app/templates/main/corpora/corpus.html.j2
index 6a55167d..df302548 100644
--- a/app/templates/main/corpora/corpus.html.j2
+++ b/app/templates/main/corpora/corpus.html.j2
@@ -69,7 +69,7 @@
{{ file.publishing_year }} |
edit
- file_download
+ file_download
delete
|
From 7dcc8c48da7587da9f141b2f73e82d3955fed65f Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Tue, 29 Oct 2019 14:35:23 +0100
Subject: [PATCH 3/3] Also delete corpus files when a corpus gets deleted
---
app/utils.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/utils.py b/app/utils.py
index e68d0682..2abecee2 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -63,5 +63,7 @@ def background_delete_corpus(app, corpus_id):
logger.warning('Called by delete_thread.')
logger.warning('Corpus id is: {}.'.format(corpus_id))
corpus = Corpus.query.filter_by(id=corpus_id).first()
- logger.warning('Corpus object is: {}'.format(corpus))
+ for corpus_file in corpus.files:
+ db.session.delete(corpus_file)
+ logger.warning('Corpus object is: {}'.format(corpus))
corpus.delete_corpus()