From cc174a563cafc7bc65df558d63dd1c3a38b92cb2 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Mon, 13 Mar 2017 21:33:19 -0400 Subject: [PATCH] Display a placeholder error document image for documents with no pages. Signed-off-by: Roberto Rosario --- mayan/apps/documents/widgets.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mayan/apps/documents/widgets.py b/mayan/apps/documents/widgets.py index f0e8a71dfc..3e5148136f 100644 --- a/mayan/apps/documents/widgets.py +++ b/mayan/apps/documents/widgets.py @@ -82,10 +82,15 @@ class DocumentPagesCarouselWidget(forms.widgets.Widget): def document_thumbnail(document, **kwargs): - return document_html_widget( - document.latest_version.pages.first(), - click_view='documents:document_display', **kwargs - ) + if document.latest_version: + return document_html_widget( + document.latest_version.pages.first(), + click_view='documents:document_display', **kwargs + ) + else: + return mark_safe( + '' + ) def document_link(document):