From 2bda500468698357ce8452e7f272c540687fcea2 Mon Sep 17 00:00:00 2001 From: Kostiantyn Stoliarskyi Date: Thu, 18 May 2023 17:50:07 +0300 Subject: [PATCH] fix test --- app/models/section.py | 8 +++++--- app/templates/book/collection_view.html | 11 +++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/models/section.py b/app/models/section.py index ff4fe48..3b2d743 100644 --- a/app/models/section.py +++ b/app/models/section.py @@ -79,7 +79,7 @@ class Section(BaseModel): @property def approved_interpretation(self): interpretation = Interpretation.query.filter_by( - approved=True, section_id=self.id + approved=True, section_id=self.id, is_deleted=False ).first() if interpretation: @@ -91,7 +91,9 @@ class Section(BaseModel): Interpretation, func.count(Interpretation.votes).label("total_votes") ) .join(InterpretationVote) - .filter(Interpretation.section_id == self.id) + .filter( + Interpretation.section_id == self.id, Interpretation.is_deleted is False + ) .group_by(Interpretation.id) .order_by(text("total_votes DESC")) ).first() @@ -100,7 +102,7 @@ class Section(BaseModel): # oldest interpretation = ( - Interpretation.query.filter_by(section_id=self.id) + Interpretation.query.filter_by(section_id=self.id, is_deleted=False) .order_by(Interpretation.created_at) .first() ) diff --git a/app/templates/book/collection_view.html b/app/templates/book/collection_view.html index f9b296f..985e6bf 100644 --- a/app/templates/book/collection_view.html +++ b/app/templates/book/collection_view.html @@ -241,13 +241,16 @@

{{ section.label }}

+ {% if not section.active_interpretations %} +

This section is empty

+ {% else %}

{{ section.approved_interpretation.text|safe }}

- Interpretation by {{section.approved_interpretation.user.username}} on {{section.approved_interpretation.created_at.strftime('%B %d, %Y')}} + Interpretation by {{section.approved_interpretation}} on {{section.approved_interpretation.created_at.strftime('%B %d, %Y')}} @@ -275,6 +278,7 @@
+ {% endif %} {% endfor %} @@ -283,18 +287,21 @@ {% for section in collection.active_sections %}

{{ section.label }}

+ {% if not section.active_interpretations %} +

This section is empty

+ {% else %}

{{ section.approved_interpretation.text|safe }}

-
Interpretation by {{section.approved_interpretation.user.username}} on {{section.approved_interpretation.created_at.strftime('%B %d, %Y')}}
+ {% endif %} {% endfor %} {% endif %} {% endfor %}