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 }}
This section is empty
+ {% else %}{{ section.approved_interpretation.text|safe }}
{{ section.label }}
+ {% if not section.active_interpretations %} +This section is empty
+ {% else %}{{ section.approved_interpretation.text|safe }}