From: Radek Czajka Date: Mon, 21 Aug 2023 11:43:15 +0000 (+0200) Subject: Fix error handling. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/2dd4071b8858c9727ee3e2c09b73b1eadef6e31e Fix error handling. --- 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,