summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/forms_common.py68
-rw-r--r--ishtar_common/models.py113
2 files changed, 175 insertions, 6 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 4dd55c38a..991968e3b 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -1390,7 +1390,7 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):
'receipt_date': FormHeader(_("Dates")),
'publisher': FormHeader(_("Publishing"), collapse=True),
'source': FormHeader(_("Source"), collapse=True),
- 'container': FormHeader(_("Container"), collapse=True),
+ 'container': FormHeader(_("Warehouse"), collapse=True),
'comment': FormHeader(_("Advanced"), collapse=True),
'finds': FormHeader(_("Related items")),
}
@@ -1501,15 +1501,60 @@ class DocumentSelect(HistorySelect):
required=False)
title = forms.CharField(label=_("Title"))
- source_type = forms.ChoiceField(label=_("Source type"), choices=[])
+ source_type = forms.ChoiceField(label=_("Type"), choices=[])
reference = forms.CharField(label=_("Reference"))
internal_reference = forms.CharField(label=_("Internal reference"))
description = forms.CharField(label=_("Description"))
+ format = forms.ChoiceField(label=_("Format"), choices=[])
+ support = forms.ChoiceField(label=_("Medium"), choices=[])
+ scale = forms.CharField(label=_("Scale"))
+ associated_url = forms.CharField(label=_("Web address"))
+ tag = forms.ChoiceField(label=_("Tag"), choices=[])
+ publisher = forms.IntegerField(
+ label=_("Publisher"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy(
+ 'autocomplete-organization',
+ args=[models.organization_type_pks_lazy(
+ settings.ISHTAR_SLUGS["document-editor"])]),
+ limit={
+ 'organization_type': [models.organization_type_pks_lazy(
+ settings.ISHTAR_SLUGS["document-editor"])]},
+ tips=models.get_publisher_label,
+ associated_model=models.Organization),
+ validators=[models.valid_id(models.Organization)])
+ language = forms.ChoiceField(label=_("Language"), choices=[])
+ isbn = forms.CharField(label=_("ISBN"))
+ issn = forms.CharField(label=_("ISSN"))
+ licenses = forms.ChoiceField(label=_("License"), choices=[])
+
comment = forms.CharField(label=_("Comment"))
additional_information = forms.CharField(
label=_("Additional informations"))
duplicate = forms.NullBooleanField(label=_("Has a duplicate"))
+ associated_file__isnull = forms.NullBooleanField(label=_("Has a file?"))
image__isnull = forms.NullBooleanField(label=_("Has an image?"))
+ source = forms.IntegerField(
+ label=_("Source"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-document'),
+ associated_model=models.Document),
+ validators=[models.valid_id(models.Document)])
+ source_free_input = forms.CharField(
+ label=_("Source - free input"))
+ warehouse_container = forms.IntegerField(
+ label=_("Warehouse - Container"), required=False,
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-container'),
+ associated_model=Container),
+ validators=[models.valid_id(Container)])
+ warehouse_container_ref = forms.IntegerField(
+ label=_("Warehouse - Reference container"), required=False,
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-container'),
+ associated_model=Container),
+ validators=[models.valid_id(Container)])
+
operation = forms.IntegerField(
label=_("Operation"), required=False,
widget=widgets.JQueryAutoComplete(
@@ -1536,15 +1581,32 @@ class DocumentSelect(HistorySelect):
validators=[models.valid_id(Find)])
find__denomination = forms.CharField(label=_("Find - denomination"),
required=False)
- container = forms.IntegerField(
+ containers = forms.IntegerField(
label=_("Container"), required=False,
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-container'),
associated_model=Container),
validators=[models.valid_id(Container)])
+ receipt_date__before = forms.DateField(
+ label=_("Receipt date before"), widget=DatePicker)
+ receipt_date__after = forms.DateField(
+ label=_("Receipt date after"), widget=DatePicker)
+ creation_date__before = forms.DateField(
+ label=_("Creation date before"), widget=DatePicker)
+ creation_date__after = forms.DateField(
+ label=_("Creation date after"), widget=DatePicker)
+ receipt_date_in_documentation__before = forms.DateField(
+ label=_("Receipt date before"), widget=DatePicker)
+ receipt_date_in_documentation__after = forms.DateField(
+ label=_("Receipt date after"), widget=DatePicker)
TYPES = [
FieldType('source_type', models.SourceType),
+ FieldType('format', models.Format),
+ FieldType('support', models.SupportType),
+ FieldType('tag', models.DocumentTag),
+ FieldType('language', models.Language),
+ FieldType('licenses', models.LicenseType),
]
PROFILE_FILTER = {
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 6364f69e8..785311764 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -5380,10 +5380,22 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel,
SearchVectorConfig("source_type__label"),
SearchVectorConfig("external_id"),
SearchVectorConfig("reference"),
+ SearchVectorConfig("internal_reference"),
SearchVectorConfig("description", "local"),
SearchVectorConfig("comment", "local"),
SearchVectorConfig("additional_information", "local"),
]
+ BASE_SEARCH_VECTORS += [
+ SearchVectorConfig('treatment_files__name'),
+ SearchVectorConfig('treatments__cached_label'),
+ SearchVectorConfig('finds__cached_label'),
+ SearchVectorConfig('context_records__cached_label'),
+ SearchVectorConfig('operations__cached_label'),
+ SearchVectorConfig('sites__cached_label'),
+ SearchVectorConfig('warehouses__name'),
+ SearchVectorConfig('containers__cached_label'),
+ SearchVectorConfig('files__cached_label')
+ ]
PARENT_SEARCH_VECTORS = ['authors', ]
M2M_SEARCH_VECTORS = [SearchVectorConfig("tags__label"), ]
@@ -5411,6 +5423,10 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel,
pgettext_lazy("key for text search", "author"),
'authors__cached_label__iexact'
),
+ 'publisher': SearchAltName(
+ pgettext_lazy("key for text search", "publisher"),
+ 'publisher__name__iexact'
+ ),
'title': SearchAltName(
pgettext_lazy("key for text search", "title"),
'title__iexact'
@@ -5431,6 +5447,59 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel,
pgettext_lazy("key for text search", "description"),
'description__iexact'
),
+ 'tag': SearchAltName(
+ pgettext_lazy("key for text search", "tag"),
+ 'tags__label__iexact'
+ ),
+ 'format': SearchAltName(
+ pgettext_lazy("key for text search", "format"),
+ 'format_type__label__iexact'
+ ),
+ 'support': SearchAltName(
+ pgettext_lazy("key for text search", "medium"),
+ 'support_type__label__iexact'
+ ),
+ 'language': SearchAltName(
+ pgettext_lazy("key for text search", "language"),
+ 'language__label__iexact'
+ ),
+ 'licenses': SearchAltName(
+ pgettext_lazy("key for text search", "license"),
+ 'licenses__label__iexact'
+ ),
+ 'scale': SearchAltName(
+ pgettext_lazy("key for text search", "scale"),
+ 'scale__iexact'
+ ),
+ 'associated_url': SearchAltName(
+ pgettext_lazy("key for text search", "url"),
+ 'associated_url__iexact'
+ ),
+ 'isbn': SearchAltName(
+ pgettext_lazy("key for text search", "isbn"),
+ 'isbn__iexact'
+ ),
+ 'issn': SearchAltName(
+ pgettext_lazy("key for text search", "issn"),
+ 'issn__iexact'
+ ),
+ 'source': SearchAltName(
+ pgettext_lazy("key for text search", "source"),
+ 'source__title__iexact'
+ ),
+ 'source_free_input': SearchAltName(
+ pgettext_lazy("key for text search", "source-free-input"),
+ 'source_free_input__iexact'
+ ),
+ 'warehouse_container': SearchAltName(
+ pgettext_lazy("key for text search", "warehouse-container"),
+ 'container__cached_label__iexact'
+ ),
+ 'warehouse_container_ref': SearchAltName(
+ pgettext_lazy("key for text search",
+ "warehouse-container-reference"),
+ 'container_ref__cached_label__iexact'
+ ),
'comment': SearchAltName(
pgettext_lazy("key for text search", "comment"),
'comment__iexact'
@@ -5467,7 +5536,7 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel,
pgettext_lazy("key for text search", "file"),
'files__cached_label__iexact'
),
- 'container': SearchAltName(
+ 'containers': SearchAltName(
pgettext_lazy("key for text search", "container"),
'containers__cached_label__iexact'
),
@@ -5483,11 +5552,49 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel,
SearchAltName(
pgettext_lazy("key for text search", "has-image"),
'image__isnull'),
+ 'associated_file__isnull':
+ SearchAltName(
+ pgettext_lazy("key for text search", "has-file"),
+ 'associated_file__isnull'),
+ 'receipt_date__before':
+ SearchAltName(
+ pgettext_lazy("key for text search", "receipt-date-before"),
+ 'receipt_date__lte'),
+ 'receipt_date__after':
+ SearchAltName(
+ pgettext_lazy("key for text search", "receipt-date-after"),
+ 'receipt_date__gte'),
+ 'receipt_date_in_documentation__before':
+ SearchAltName(
+ pgettext_lazy("key for text search",
+ "receipt-in-documentation-date-before"),
+ 'receipt_date_in_documentation__lte'),
+ 'receipt_date_in_documentation__after':
+ SearchAltName(
+ pgettext_lazy("key for text search",
+ "receipt-in-documentation-date-after"),
+ 'receipt_date_in_documentation__gte'),
+ 'creation_date__before':
+ SearchAltName(
+ pgettext_lazy("key for text search", "creation-date-before"),
+ 'creation_date__lte'),
+ 'creation_date__after':
+ SearchAltName(
+ pgettext_lazy("key for text search", "creation-date-after"),
+ 'creation_date__gte'),
}
ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES)
# search parameters
- REVERSED_BOOL_FIELDS = ['image__isnull']
+ REVERSED_BOOL_FIELDS = ['image__isnull', 'associated_file__isnull']
+ DATED_FIELDS = [
+ 'receipt_date__lte',
+ 'receipt_date__gte',
+ 'receipt_date_in_documentation__lte',
+ 'receipt_date_in_documentation__gte',
+ 'creation_date__lte',
+ 'creation_date__gte',
+ ]
objects = ExternalIdManager()
RELATIVE_SESSION_NAMES = [
@@ -5561,7 +5668,7 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel,
support_type = models.ForeignKey(SupportType, verbose_name=_("Support"),
on_delete=models.SET_NULL,
blank=True, null=True, )
- format_type = models.ForeignKey(Format, verbose_name=_("Format"),
+ format_type = models.ForeignKey(Format, verbose_name=_("Medium"),
on_delete=models.SET_NULL,
blank=True, null=True)
scale = models.CharField(_("Scale"), max_length=30, null=True,