diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-12-20 20:29:51 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-11 17:30:46 +0100 |
commit | 0797c57b6f6b9921a1d5df2b5552f646af28952d (patch) | |
tree | 54306339d88c00d14955ed67629edaf9d8a02231 /ishtar_common/models.py | |
parent | 330215cf864ad3a917d51d6be15d68f360c166dc (diff) | |
download | Ishtar-0797c57b6f6b9921a1d5df2b5552f646af28952d.tar.bz2 Ishtar-0797c57b6f6b9921a1d5df2b5552f646af28952d.zip |
Image: form to change main image - fix image in sheets
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 9 |
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(): |