diff --git a/app/models/book.py b/app/models/book.py index 5e1815a..f0459b6 100644 --- a/app/models/book.py +++ b/app/models/book.py @@ -92,3 +92,27 @@ class Book(BaseModel): ) return interpretations + + @property + def interpretations(self): + interpretations = ( + db.session.query( + m.Interpretation, + ) + .filter( + and_( + m.BookVersion.id == self.last_version.id, + m.Section.version_id == m.BookVersion.id, + m.Collection.id == m.Section.collection_id, + m.Interpretation.section_id == m.Section.id, + m.BookVersion.is_deleted.is_(False), + m.Interpretation.is_deleted.is_(False), + m.Section.is_deleted.is_(False), + m.Collection.is_deleted.is_(False), + ), + ) + .order_by(m.Interpretation.created_at.desc()) + .all() + ) + + return interpretations diff --git a/app/templates/book/all.html b/app/templates/book/all.html index 6290148..c6dd39a 100644 --- a/app/templates/book/all.html +++ b/app/templates/book/all.html @@ -27,7 +27,7 @@ -

{{ book.approved_interpretations|length }}

+

{{ book.interpretations|length }}

diff --git a/app/templates/book/favorite_books.html b/app/templates/book/favorite_books.html index 64c510a..33ff647 100644 --- a/app/templates/book/favorite_books.html +++ b/app/templates/book/favorite_books.html @@ -41,7 +41,7 @@ -

{{ book.approved_interpretations|length }}

+

{{ book.interpretations|length }}

diff --git a/app/templates/book/my_library.html b/app/templates/book/my_library.html index 2fe4123..ec003c7 100644 --- a/app/templates/book/my_library.html +++ b/app/templates/book/my_library.html @@ -47,7 +47,7 @@ -

{{ book.approved_interpretations|length }}

+

{{ book.interpretations|length }}

diff --git a/app/templates/home/index.html b/app/templates/home/index.html index 74d2c4a..08e8362 100644 --- a/app/templates/home/index.html +++ b/app/templates/home/index.html @@ -117,7 +117,7 @@ -

{{ book.approved_interpretations|length }}

+

{{ book.interpretations|length }}

diff --git a/app/templates/search/search_results_books.html b/app/templates/search/search_results_books.html index 5887dcb..20d3b0b 100644 --- a/app/templates/search/search_results_books.html +++ b/app/templates/search/search_results_books.html @@ -62,7 +62,7 @@ -

{{ book.approved_interpretations|length }}

+

{{ book.interpretations|length }}

diff --git a/app/templates/search/tag_search_results_books.html b/app/templates/search/tag_search_results_books.html index 6324f1a..cc5fcb3 100644 --- a/app/templates/search/tag_search_results_books.html +++ b/app/templates/search/tag_search_results_books.html @@ -50,7 +50,7 @@ -

{{ book.approved_interpretations|length }}

+

{{ book.interpretations|length }}

diff --git a/app/templates/user/profile.html b/app/templates/user/profile.html index a4df4ab..2bcdc5d 100644 --- a/app/templates/user/profile.html +++ b/app/templates/user/profile.html @@ -63,7 +63,7 @@ -

{{ book.approved_interpretations|length }}

+

{{ book.interpretations|length }}