fix stats api
[redakcja.git] / src / documents / views.py
index f4c8561..0fbb3b9 100644 (file)
@@ -362,14 +362,21 @@ def book(request, slug):
     publish_error = book.publishable_error()
     publishable = publish_error is None
 
     publish_error = book.publishable_error()
     publishable = publish_error is None
 
+    stats = None
     try:
         doc = book.wldocument(librarian2=True)
     except:
         doc = 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,
 
     return render(request, "documents/book_detail.html", {
         "book": book,
         "doc": doc,
+        "stats": stats,
         "publishable": publishable,
         "publishable_error": publish_error,
         "form": form,
         "publishable": publishable,
         "publishable_error": publish_error,
         "form": form,