From b0f61b28fe270bc61b9b74fe80b72602ecf17cf3 Mon Sep 17 00:00:00 2001 From: Inga Kirschnick Date: Thu, 2 Feb 2023 09:14:50 +0100 Subject: [PATCH] Small changes on the Corpus page --- app/corpora/routes.py | 14 +++-- app/templates/corpora/corpus.html.j2 | 85 +++++++++++++++++++++------- 2 files changed, 75 insertions(+), 24 deletions(-) diff --git a/app/corpora/routes.py b/app/corpora/routes.py index a5035087..f2128479 100644 --- a/app/corpora/routes.py +++ b/app/corpora/routes.py @@ -81,10 +81,18 @@ def corpus(corpus_id): db.session.commit() flash('Your changes have been saved') return redirect(url_for('.corpus', corpus_id=corpus.id)) + # if corpus.following_users == [None]: + # following_users = [] + # else: + # following_users = [ + # u.to_json_serializeable() for u + # in corpus.following_users + # ] return render_template( 'corpora/corpus.html.j2', corpus_settings_form=corpus_settings_form, corpus=corpus, + # following_users=following_users, title='Corpus' ) @@ -277,10 +285,8 @@ def import_corpus(): def export_corpus(corpus_id): abort(503) -@bp.route('//follow') +@bp.route('//follow', methods=['GET', 'POST']) @login_required -# TODO: Wenn Query Paramter genutzt wird, prüfen, ob user_id ungleich current_user.id ist und dann gucken, ob es ein Admin ist. -# Sonst 403. def follow_corpus(corpus_id): corpus = Corpus.query.get_or_404(corpus_id) user_hashid = request.args.get('user_id') @@ -297,7 +303,7 @@ def follow_corpus(corpus_id): db.session.commit() return {}, 202 -@bp.route('//unfollow') +@bp.route('//unfollow', methods=['GET', 'POST']) @login_required def unfollow_corpus(corpus_id): corpus = Corpus.query.get_or_404(corpus_id) diff --git a/app/templates/corpora/corpus.html.j2 b/app/templates/corpora/corpus.html.j2 index 00e10bba..0f7b0bf4 100644 --- a/app/templates/corpora/corpus.html.j2 +++ b/app/templates/corpora/corpus.html.j2 @@ -10,10 +10,15 @@
-

+ {#

#} +

{{ corpus.title }}

{% if not corpus.user == current_user %} + {% if current_user.is_following_corpus(corpus) %} + addUnfollow Corpus + {% elif not current_user.is_following_corpus(corpus) %} addFollow Corpus {% endif %} + {% endif %}

 

@@ -90,6 +95,7 @@

{{ wtf.render_field(corpus_settings_form.is_public) }} +
{{ wtf.render_field(corpus_settings_form.submit, material_icon='send') }} @@ -98,6 +104,14 @@
{% endif %} +
+
+
+ Corpus followers +
+
+
+
{% endblock page_content %} @@ -106,25 +120,56 @@ {{ super() }} {% endblock scripts %}