From 2d4559e4fe884b0b25d4c123977068845435a35e Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Wed, 6 Nov 2019 10:04:01 +0100 Subject: [PATCH 1/2] Show buttons only on wanted status --- app/templates/corpora/corpus.html.j2 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/templates/corpora/corpus.html.j2 b/app/templates/corpora/corpus.html.j2 index 9f934ee3..a686aac2 100644 --- a/app/templates/corpora/corpus.html.j2 +++ b/app/templates/corpora/corpus.html.j2 @@ -61,6 +61,12 @@ statusElement.classList.remove(...Object.values(CorpusList.STATUS_COLORS)); statusElement.classList.add(CorpusList.STATUS_COLORS[status] || CorpusList.STATUS_COLORS['default']); statusElement.innerText = status; + if (status === 'prepared') { + var analyseBtn = document.getElementById('analyse'); + analyseBtn.classList.remove('hide'); + var prepareBtn = document.getElementById('prepare'); + prepareBtn.classList.add('hide') + } } } @@ -87,11 +93,9 @@
- {% if corpus.status == 'prepared' %} - helpAnalyse - {% endif %} + helpAnalyse {% if corpus.files[0] is defined %} - whatshotPrepare + whatshotPrepare {% endif %} deleteDelete Corpus
From 64dce7ed28f0585df9984c090d61df1a43acaa12 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Wed, 6 Nov 2019 10:04:29 +0100 Subject: [PATCH 2/2] Set status on upload, edit, or delete --- app/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models.py b/app/models.py index 5b86fa28..470e5c6a 100644 --- a/app/models.py +++ b/app/models.py @@ -422,6 +422,7 @@ class CorpusFile(db.Model): except: logger.warning('[ERROR] CorpusFile.delete') return + self.corpus.status = 'unprepared' db.session.delete(self) db.session.commit() @@ -435,6 +436,8 @@ class CorpusFile(db.Model): text_node.set('publishing_year', str(self.publishing_year)) text_node.set('title', self.title) element_tree.write(file) + self.corpus.status = 'unprepared' + db.session.commit() class Corpus(db.Model):