summaryrefslogtreecommitdiff
path: root/ishtar_common/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2023-12-18 18:56:31 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-02-05 10:51:52 +0100
commitff02c4b717b665f3671cd8168c91a41dc06e1728 (patch)
treed5de7905864667f73939ecd45ca8c938167bd103 /ishtar_common/forms.py
parente5c704cbe7d3bd3e805aee3b767267539e2a963e (diff)
downloadIshtar-ff02c4b717b665f3671cd8168c91a41dc06e1728.tar.bz2
Ishtar-ff02c4b717b665f3671cd8168c91a41dc06e1728.zip
✨ imports: add search criteria
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r--ishtar_common/forms.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index c560dc5ec..b81b42bc6 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -1000,7 +1000,28 @@ class HistorySelect(CustomForm, TableSelect):
self.custom_form_ordering()
-class DocumentItemSelect(HistorySelect):
+class ImportSelect(HistorySelect):
+ imports = forms.IntegerField(
+ label=_("Imported from"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy(
+ 'autocomplete-import',
+ ),
+ associated_model=models.Import),
+ validators=[models.valid_id(models.Import)])
+ CURRENT_FIELDS = [
+ "imports",
+ ] + HistorySelect.CURRENT_FIELDS
+ _explicit_ordering = True
+
+ def __init__(self, *args, **kwargs):
+ user = kwargs.get("user", None)
+ super().__init__(*args, **kwargs)
+ if not user or (not user.has_perm("view_import") and not user.has_perm("view_own_import")):
+ self.fields.pop("imports")
+
+
+class DocumentItemSelect(ImportSelect):
documents__image__isnull = forms.NullBooleanField(label=_("Has an image?"))
documents__associated_file__isnull = forms.NullBooleanField(
label=_("Has an attached file?")
@@ -1012,7 +1033,7 @@ class DocumentItemSelect(HistorySelect):
"documents__image__isnull",
"documents__associated_file__isnull",
"documents__associated_url__isnull",
- ] + HistorySelect.CURRENT_FIELDS
+ ] + ImportSelect.CURRENT_FIELDS
_explicit_ordering = True