From 4dc331b2fe9c37caa58c9043bac2bffd2e618138 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Tue, 3 Sep 2019 15:58:40 +0200 Subject: [PATCH] Add corpus page. --- app/main/views.py | 21 +++++- app/templates/main/corpora/corpus.html.j2 | 90 +++++++++++++++++++++++ app/templates/main/jobs/job.html.j2 | 2 - 3 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 app/templates/main/corpora/corpus.html.j2 diff --git a/app/main/views.py b/app/main/views.py index 676b9528..773aaf08 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -31,11 +31,28 @@ def corpus(corpus_id): files[file]['path'] = os.path.join(file) return render_template('main/corpora/corpus.html.j2', + corpus_id=corpus.id, files=files, - corpus=corpus, title='Corpus') +@main.route('/corpora//download') +@login_required +def corpus_download(corpus_id): + file = request.args.get('file') + corpus = current_user.corpora.filter_by(id=corpus_id).first() + if not file or not corpus: + print('File not found.') + abort(404) + dir = os.path.join(current_app.config['OPAQUE_STORAGE'], + str(current_user.id), + 'corpora', + str(corpus.id)) + return send_from_directory(as_attachment=True, + directory=dir, + filename=file) + + @main.route('/dashboard', methods=['GET', 'POST']) @login_required def dashboard(): @@ -100,7 +117,7 @@ def job(job_id): return render_template('main/jobs/job.html.j2', files=files, - job=job, + job_id=job.id, title='Job') diff --git a/app/templates/main/corpora/corpus.html.j2 b/app/templates/main/corpora/corpus.html.j2 new file mode 100644 index 00000000..fe6c6832 --- /dev/null +++ b/app/templates/main/corpora/corpus.html.j2 @@ -0,0 +1,90 @@ +{% extends "base.html.j2" %} + +{% block page_content %} + + +
+

+

+
+ +
+
+
+ Chronometrics +
+
+
+ + +
+
+
+ Files +

+ {% for file in files %} + + file_download{{ file }} + + {% endfor %} +

+
+
+ +{% endblock %} diff --git a/app/templates/main/jobs/job.html.j2 b/app/templates/main/jobs/job.html.j2 index 6b02d6a9..bf655dfb 100644 --- a/app/templates/main/jobs/job.html.j2 +++ b/app/templates/main/jobs/job.html.j2 @@ -53,8 +53,6 @@ pathArray = operation.path.split("/").slice(1); if (pathArray[0] != this.jobId) {continue;} switch(operation.op) { - case "add": - break; case "delete": location.reload(); break;