From fede3ec0bad4d026c4d0b79959b20ff12769f4e9 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 28 May 2017 01:06:12 -0400 Subject: [PATCH] Return an empty DocumentPage Queryset when a document has no latest version. Signed-off-by: Roberto Rosario --- mayan/apps/documents/models.py | 2 +- mayan/apps/documents/widgets.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mayan/apps/documents/models.py b/mayan/apps/documents/models.py index a566bc5f90..c0c02a3136 100644 --- a/mayan/apps/documents/models.py +++ b/mayan/apps/documents/models.py @@ -319,7 +319,7 @@ class Document(models.Model): return self.latest_version.pages except AttributeError: # Document has no version yet - return 0 + return DocumentPage.objects.none() class DeletedDocument(Document): diff --git a/mayan/apps/documents/widgets.py b/mayan/apps/documents/widgets.py index 2bd1b0e7bc..92dae0d3e1 100644 --- a/mayan/apps/documents/widgets.py +++ b/mayan/apps/documents/widgets.py @@ -285,7 +285,7 @@ class DocumentThumbnailWidget(BaseDocumentThumbnailWidget): return getattr(instance, 'label', None) def is_valid(self, instance): - return instance.latest_version.pages.all() + return instance.pages class DocumentPageThumbnailWidget(BaseDocumentThumbnailWidget):