summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-03-11 13:27:04 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2020-03-11 13:27:04 +0100
commit3fd126b25be6a50c49b4525941d216fa92f727b0 (patch)
treec248b4e8b129d017373af2a07d399f5ca82717b1 /ishtar_common/models.py
parent9429df335283ff6de8c0e21778bb0e7fbda6b149 (diff)
downloadIshtar-3fd126b25be6a50c49b4525941d216fa92f727b0.tar.bz2
Ishtar-3fd126b25be6a50c49b4525941d216fa92f727b0.zip
Searc criteria: add has image/file/url criteria for all document items
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index dc2fef815..5fa668faf 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1818,6 +1818,21 @@ class QRCodeItem(models.Model, ImageContainerModel):
class DocumentItem(object):
+ ALT_NAMES = {
+ 'documents__image__isnull':
+ SearchAltName(
+ pgettext_lazy("key for text search", "has-image"),
+ 'documents__image__isnull'),
+ 'documents__associated_url__isnull':
+ SearchAltName(
+ pgettext_lazy("key for text search", "has-url"),
+ 'documents__associated_url__isnull'),
+ 'documents__associated_file__isnull':
+ SearchAltName(
+ pgettext_lazy("key for text search", "has-attached-file"),
+ 'documents__associated_file__isnull'),
+ }
+
def public_representation(self):
images = []
if getattr(self, "main_image", None):
@@ -5600,6 +5615,8 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel,
no_path_change = 'no_path_change' in kwargs \
and kwargs.pop('no_path_change')
self.set_index()
+ if not self.associated_url:
+ self.associated_url = None
super(Document, self).save(*args, **kwargs)
if self.image and not no_path_change and \