diff options
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 |
commit | c9b07622ebf6f6dcceff3d6906d3ed33d74f24fd (patch) | |
tree | c248b4e8b129d017373af2a07d399f5ca82717b1 /ishtar_common/models.py | |
parent | df67b2c757e813512a6e5f1ea31f8a4693444013 (diff) | |
download | Ishtar-c9b07622ebf6f6dcceff3d6906d3ed33d74f24fd.tar.bz2 Ishtar-c9b07622ebf6f6dcceff3d6906d3ed33d74f24fd.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.py | 17 |
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 \ |