From f06508b412f90d50101862f5961375a9221d79c1 Mon Sep 17 00:00:00 2001 From: Inga Kirschnick Date: Thu, 9 Feb 2023 11:21:03 +0100 Subject: [PATCH] New Public Corpus Page --- app/corpora/routes.py | 3 + .../js/ResourceLists/PublicCorpusFileList.js | 15 ++++ app/templates/_scripts.html.j2 | 1 + app/templates/corpora/corpus.html.j2 | 3 +- app/templates/corpora/public_corpus.html.j2 | 77 ++++++++++++------- 5 files changed, 69 insertions(+), 30 deletions(-) create mode 100644 app/static/js/ResourceLists/PublicCorpusFileList.js diff --git a/app/corpora/routes.py b/app/corpora/routes.py index 63af1b07..d89b7567 100644 --- a/app/corpora/routes.py +++ b/app/corpora/routes.py @@ -298,6 +298,7 @@ def follow_corpus(corpus_id): if not user.is_following_corpus(corpus): user.follow_corpus(corpus) db.session.commit() + # flash('Hallo Inga Kirschnick') return {}, 202 @bp.route('//unfollow', methods=['GET', 'POST']) @@ -336,8 +337,10 @@ def remove_permission(corpus_id, user_id, permission): @bp.route('/public/') def public_corpus(corpus_id): corpus = Corpus.query.get_or_404(corpus_id) + corpus_files = [cf.to_json_serializeable() for cf in CorpusFile.query.filter_by(corpus_id = corpus_id).all()] return render_template( 'corpora/public_corpus.html.j2', corpus=corpus, + corpus_files=corpus_files, title=corpus.title ) diff --git a/app/static/js/ResourceLists/PublicCorpusFileList.js b/app/static/js/ResourceLists/PublicCorpusFileList.js new file mode 100644 index 00000000..51362138 --- /dev/null +++ b/app/static/js/ResourceLists/PublicCorpusFileList.js @@ -0,0 +1,15 @@ +class PublicCorpusFileList extends CorpusFileList { + get item() { + return ` + + + + + + + file_download + + + `.trim(); + } +} diff --git a/app/templates/_scripts.html.j2 b/app/templates/_scripts.html.j2 index 95406079..64629b6c 100644 --- a/app/templates/_scripts.html.j2 +++ b/app/templates/_scripts.html.j2 @@ -20,6 +20,7 @@ 'js/RessourceDisplays/JobDisplay.js', 'js/ResourceLists/ResourceList.js', 'js/ResourceLists/CorpusFileList.js', + 'js/ResourceLists/PublicCorpusFileList.js', 'js/ResourceLists/CorpusList.js', 'js/ResourceLists/JobList.js', 'js/ResourceLists/JobInputList.js', diff --git a/app/templates/corpora/corpus.html.j2 b/app/templates/corpora/corpus.html.j2 index c29da972..5311e92b 100644 --- a/app/templates/corpora/corpus.html.j2 +++ b/app/templates/corpora/corpus.html.j2 @@ -10,8 +10,7 @@
- {#

#} -

{{ corpus.title }}

+

{% if not corpus.user == current_user %} {% if current_user.is_following_corpus(corpus) %} addUnfollow Corpus diff --git a/app/templates/corpora/public_corpus.html.j2 b/app/templates/corpora/public_corpus.html.j2 index f9cb4bc9..90a45f62 100644 --- a/app/templates/corpora/public_corpus.html.j2 +++ b/app/templates/corpora/public_corpus.html.j2 @@ -8,9 +8,27 @@

{{ title }}

+
+
+

Status:

+

+
+

Description: {{ corpus.description }}


@@ -25,6 +43,13 @@
+
+
+ Corpus files +
+
+
+
@@ -33,45 +58,42 @@ {% block scripts %} {{ super() }}