From 2dd4071b8858c9727ee3e2c09b73b1eadef6e31e Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 21 Aug 2023 13:43:15 +0200 Subject: [PATCH 1/1] Fix error handling. --- src/documents/templates/documents/book_detail.html | 6 ++---- src/documents/views.py | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/documents/templates/documents/book_detail.html b/src/documents/templates/documents/book_detail.html index a2dea020..08d8c36f 100644 --- a/src/documents/templates/documents/book_detail.html +++ b/src/documents/templates/documents/book_detail.html @@ -200,7 +200,7 @@ - {% if doc %} + {% if stats %}

{% trans "Statistics" %}

@@ -221,9 +221,7 @@ - {% with stats=doc.get_statistics %} - {% include 'documents/book_stats.html' with book=doc stats=stats depth=0 %} - {% endwith %} + {% include 'documents/book_stats.html' with book=doc stats=stats depth=0 %}
diff --git a/src/documents/views.py b/src/documents/views.py index f4c85612..0fbb3b9f 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -362,14 +362,21 @@ def book(request, slug): publish_error = book.publishable_error() publishable = publish_error is None + stats = None try: doc = book.wldocument(librarian2=True) except: doc = None + else: + try: + stats = doc.get_statistic() + except: + pass return render(request, "documents/book_detail.html", { "book": book, "doc": doc, + "stats": stats, "publishable": publishable, "publishable_error": publish_error, "form": form, -- 2.20.1