summaryrefslogtreecommitdiff
path: root/ishtar_common/forms.py
diff options
context:
space:
mode:
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