From c82f90c6fb6b122ae17704a6d39b26ac66ef0d3c Mon Sep 17 00:00:00 2001 From: Kostiantyn Stoliarskyi Date: Thu, 25 May 2023 16:51:42 +0300 Subject: [PATCH] clean done --- app/controllers/breadcrumbs.py | 15 ++---- app/templates/book/add_section_modal.html | 2 +- app/templates/book/interpretation_view.html | 9 +--- app/templates/book/qa_view.html | 7 +-- app/views/book/book.py | 56 +++++++++++---------- 5 files changed, 35 insertions(+), 54 deletions(-) diff --git a/app/controllers/breadcrumbs.py b/app/controllers/breadcrumbs.py index 8aca599..250c90a 100644 --- a/app/controllers/breadcrumbs.py +++ b/app/controllers/breadcrumbs.py @@ -39,7 +39,7 @@ def create_breadcrumbs( crumples += [ s.BreadCrumb( type=s.BreadCrumbType.AuthorBookList, - url="#", + url="", label=book.owner.username + "'s books", ) ] @@ -60,11 +60,7 @@ def create_breadcrumbs( crumples += [ s.BreadCrumb( type=s.BreadCrumbType.Collection, - url=url_for( - "book.sub_collection_view", - book_id=book_id, - collection_id=collection_id, - ), + url="", label=collection.label, ) ] @@ -72,12 +68,7 @@ def create_breadcrumbs( crumples += [ s.BreadCrumb( type=s.BreadCrumbType.Section, - url=url_for( - "book.section_view", - book_id=book_id, - collection_id=collection_path[0], - sub_collection_id=collection_path[-1], - ), + url="", label=collection.label, ) ] diff --git a/app/templates/book/add_section_modal.html b/app/templates/book/add_section_modal.html index 5d1e57c..9aa680f 100644 --- a/app/templates/book/add_section_modal.html +++ b/app/templates/book/add_section_modal.html @@ -18,7 +18,7 @@
- +
diff --git a/app/templates/book/interpretation_view.html b/app/templates/book/interpretation_view.html index c97a4cf..73cd16c 100644 --- a/app/templates/book/interpretation_view.html +++ b/app/templates/book/interpretation_view.html @@ -2,22 +2,15 @@ {% extends 'base.html' %} {% if current_user.is_authenticated %} -{% include 'book/delete_section_modal.html' %} -{% include 'book/edit_section_modal.html' %} {% include 'book/approve_interpretation_modal.html' %} - -{% set show_delete_section = True %} - -{% set show_edit_section = True %} {% block right_sidebar %} - {% include 'book/right_sidebar.html' %} {% endblock %} {% endif %} {% block content %} {% include 'book/breadcrumbs_navigation.html'%} -
+
diff --git a/app/templates/book/qa_view.html b/app/templates/book/qa_view.html index 4858349..fa5fcd9 100644 --- a/app/templates/book/qa_view.html +++ b/app/templates/book/qa_view.html @@ -4,21 +4,16 @@ {% if current_user.is_authenticated %} -{% include 'book/delete_interpretation_modal.html' %} {% include 'book/delete_comment_modal.html' %} {% include 'book/edit_comment_modal.html' %} -{% include 'book/edit_interpretation_modal.html' %} -{% set show_edit_interpretation = True %} -{% set show_delete_interpretation = True %} {% block right_sidebar %} -{% include 'book/right_sidebar.html' %} {% endblock %} {% endif %} {% block content %} {% include 'book/breadcrumbs_navigation.html'%} -
+

{{ section.label }} diff --git a/app/views/book/book.py b/app/views/book/book.py index 7ccde09..8501295 100644 --- a/app/views/book/book.py +++ b/app/views/book/book.py @@ -174,34 +174,36 @@ def favorite_books(): @bp.route("/my_contributions", methods=["GET"]) def my_contributions(): - interpretations = ( - db.session.query( - m.Interpretation, - ) - .filter( - or_( - and_( - m.Interpretation.id == m.Comment.interpretation_id, - m.Comment.user_id == current_user.id, - m.Comment.is_deleted.is_(False), - m.Interpretation.is_deleted.is_(False), - ), - and_( - m.Interpretation.user_id == current_user.id, - m.Interpretation.is_deleted.is_(False), - ), + if current_user.is_authenticated: + interpretations = ( + db.session.query( + m.Interpretation, ) + .filter( + or_( + and_( + m.Interpretation.id == m.Comment.interpretation_id, + m.Comment.user_id == current_user.id, + m.Comment.is_deleted.is_(False), + m.Interpretation.is_deleted.is_(False), + ), + and_( + m.Interpretation.user_id == current_user.id, + m.Interpretation.is_deleted.is_(False), + ), + ) + ) + .group_by(m.Interpretation.id) + .order_by(m.Interpretation.created_at.desc()) ) - .group_by(m.Interpretation.id) - .order_by(m.Interpretation.created_at.desc()) - ) - pagination = create_pagination(total=interpretations.count()) + pagination = create_pagination(total=interpretations.count()) - return render_template( - "book/my_contributions.html", - interpretations=interpretations.paginate( - page=pagination.page, per_page=pagination.per_page - ), - page=pagination, - ) + return render_template( + "book/my_contributions.html", + interpretations=interpretations.paginate( + page=pagination.page, per_page=pagination.per_page + ), + page=pagination, + ) + return render_template("book/my_contributions.html", interpretations=[])