summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 6cf2846a6..e1318ef62 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1392,13 +1392,11 @@ class DocumentItem(object):
@property
def images_without_main_image(self):
- if not hasattr(self, 'documents'):
- return Document.objects.none()
if not hasattr(self, 'main_image'):
return self.images
return self.documents.filter(
image__isnull=False).exclude(
- image="", pk=self.main_image.pk).order_by("pk")
+ image="").exclude(pk=self.main_image.pk).order_by("pk")
def get_extra_actions(self, request):
"""
@@ -3893,6 +3891,11 @@ class Document(OwnPerms, ImageModel, FullSearch, Imported):
pk=self.pk, image__isnull=False).exclude(image='')
@property
+ def main_image(self):
+ if self.images.count():
+ return self.images.all()[0]
+
+ @property
def has_related(self):
for rel in self.RELATED_MODELS:
if getattr(self, rel).count():