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 | 3fd126b25be6a50c49b4525941d216fa92f727b0 (patch) | |
tree | c248b4e8b129d017373af2a07d399f5ca82717b1 /archaeological_finds | |
parent | 9429df335283ff6de8c0e21778bb0e7fbda6b149 (diff) | |
download | Ishtar-3fd126b25be6a50c49b4525941d216fa92f727b0.tar.bz2 Ishtar-3fd126b25be6a50c49b4525941d216fa92f727b0.zip |
Searc criteria: add has image/file/url criteria for all document items
Diffstat (limited to 'archaeological_finds')
-rw-r--r-- | archaeological_finds/forms.py | 15 | ||||
-rw-r--r-- | archaeological_finds/forms_treatments.py | 9 | ||||
-rw-r--r-- | archaeological_finds/models_finds.py | 9 | ||||
-rw-r--r-- | archaeological_finds/models_treatments.py | 17 |
4 files changed, 27 insertions, 23 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 316253a7a..90805e656 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -56,7 +56,7 @@ from ishtar_common import widgets from ishtar_common.forms import CustomForm, CustomFormSearch, FormSet, \ FloatField, reverse_lazy, TableSelect, get_now, FinalForm, \ ManageOldType, FieldType, IshtarForm, FormHeader, QAForm, HistorySelect, \ - MultiSearchForm, LockForm + MultiSearchForm, LockForm, DocumentItemSelect from ishtar_common.forms_common import get_town_field from ishtar_common.models import valid_id, valid_ids, get_current_profile, \ SpatialReferenceSystem, Area, OperationType, IshtarUser @@ -524,8 +524,8 @@ class ResultingFindsForm(CustomForm, ManageOldType): label=_(u"Prefix label for resulting finds"), validators=[validators.MaxLengthValidator(200)], help_text=_( - u'E.g.: with a prefix "item-", each resulting item will be named ' - u'"item-1", "item-2", "item-3"') + 'E.g.: with a prefix "item-", each resulting item will be named ' + '"item-1", "item-2", "item-3"') ) resultings_start_number = forms.IntegerField( label=_(u"Numbering starting from"), initial=1, min_value=0 @@ -908,9 +908,9 @@ DatingFormSet.form_admin_name = _(u"Find - 040 - Dating") DatingFormSet.form_slug = "find-040-dating" -class FindSelect(HistorySelect): +class FindSelect(DocumentItemSelect): _model = models.Find - form_admin_name = _(u"Find - 001 - Search") + form_admin_name = _("Find - 001 - Search") form_slug = "find-001-search" FORM_FILTERS = [ (_(u"Find origin"), [ @@ -1051,9 +1051,9 @@ class FindSelect(HistorySelect): reverse_lazy('autocomplete-materialtype'), associated_model=models.MaterialType), ) - material_type_quality = forms.ChoiceField(label=_(u"Material type quality"), + material_type_quality = forms.ChoiceField(label=_("Material type quality"), choices=[]) - material_comment = forms.CharField(label=_(u"Comment on the material")) + material_comment = forms.CharField(label=_("Comment on the material")) object_types = forms.IntegerField( label=_(u"Object type"), widget=widgets.JQueryAutoComplete( @@ -1182,7 +1182,6 @@ class FindSelect(HistorySelect): appraisal_date__before = forms.DateField( label=_(u"Appraisal date before"), widget=DatePicker) - documents__image__isnull = forms.NullBooleanField(label=_(u"Has an image?")) loan = forms.NullBooleanField(label=_(u"Loan?")) treatments_file_end_date = forms.DateField( label=_(u"Treatment file end date before"), widget=DatePicker diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py index f03dec18a..b80b6c0fe 100644 --- a/archaeological_finds/forms_treatments.py +++ b/archaeological_finds/forms_treatments.py @@ -33,8 +33,8 @@ from archaeological_warehouse.models import Warehouse, Container from bootstrap_datepicker.widgets import DatePicker from ishtar_common import widgets from ishtar_common.forms import reverse_lazy, TableSelect, FinalForm, \ - ManageOldType, CustomForm, FieldType, IshtarForm, HistorySelect, \ - MultiSearchForm + ManageOldType, CustomForm, FieldType, IshtarForm, \ + DocumentItemSelect, MultiSearchForm from ishtar_common.models import Person, valid_id, valid_ids, Organization, \ get_current_profile @@ -43,7 +43,7 @@ logger = logging.getLogger(__name__) # Treatment -class TreatmentSelect(HistorySelect): +class TreatmentSelect(DocumentItemSelect): _model = models.Treatment form_admin_name = _(u"Treatment - 001 - Search") form_slug = "treatment-001-search" @@ -63,7 +63,6 @@ class TreatmentSelect(HistorySelect): associated_model=Person), label=_(u"Scientific monitoring manager")) treatment_types = forms.ChoiceField(label=_(u"Treatment type"), choices=[]) - documents__image__isnull = forms.NullBooleanField(label=_(u"Has an image?")) def __init__(self, *args, **kwargs): super(TreatmentSelect, self).__init__(*args, **kwargs) @@ -662,7 +661,7 @@ class AdministrativeActTreatmentModifForm( # treatment requests -class TreatmentFileSelect(HistorySelect): +class TreatmentFileSelect(DocumentItemSelect): _model = models.TreatmentFile form_admin_name = _(u"Treatment file - 001 - Search") form_slug = "treatmentfile-001-search" diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index ad5c803fa..328821386 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -880,7 +880,9 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, ) # search parameters - REVERSED_BOOL_FIELDS = ['documents__image__isnull'] + REVERSED_BOOL_FIELDS = ['documents__image__isnull', + 'documents__associated_url__isnull', + 'documents__associated_file__isnull'] BOOL_FIELDS = ['is_complete'] RELATION_TYPES_PREFIX = { 'ope_relation_types': @@ -1042,10 +1044,6 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, SearchAltName( pgettext_lazy("key for text search", "checked"), 'checked_type__label__iexact'), - 'documents__image__isnull': - SearchAltName( - pgettext_lazy("key for text search", "has-image"), - 'documents__image__isnull'), 'container_ref__location': SearchAltName( pgettext_lazy("key for text search", "location"), @@ -1364,6 +1362,7 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, ), } ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES) + ALT_NAMES.update(DocumentItem.ALT_NAMES) DYNAMIC_REQUESTS = { 'current_division': DynamicRequest( diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index a8a06ae27..071d80af1 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -74,7 +74,11 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem, 'person__cached_label', 'start_date', 'downstream_cached_label', 'upstream_cached_label') - REVERSED_BOOL_FIELDS = ['documents__image__isnull'] + REVERSED_BOOL_FIELDS = [ + 'documents__image__isnull', + 'documents__associated_file__isnull', + 'documents__associated_url__isnull', + ] EXTRA_REQUEST_KEYS = { "downstream_cached_label": "downstream__cached_label", "upstream_cached_label": "upstream__cached_label", @@ -115,10 +119,6 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem, pgettext_lazy("key for text search", "index"), 'index' ), - 'documents__image__isnull': SearchAltName( - pgettext_lazy("key for text search", "has-image"), - 'documents__image__isnull' - ), 'treatment_types': SearchAltName( pgettext_lazy("key for text search", "type"), 'treatment_types__label__iexact' @@ -129,6 +129,7 @@ class Treatment(DashboardFormItem, ValueGetter, DocumentItem, ), } ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES) + ALT_NAMES.update(DocumentItem.ALT_NAMES) HISTORICAL_M2M = [ 'treatment_types', ] @@ -914,6 +915,11 @@ class TreatmentFile(DashboardFormItem, ClosedItem, DocumentItem, "in_charge__pk": "in_charge__pk", # used by dynamic_table_documents "applicant__pk": "applicant__pk", # used by dynamic_table_documents } + REVERSED_BOOL_FIELDS = [ + 'documents__image__isnull', + 'documents__associated_file__isnull', + 'documents__associated_url__isnull', + ] # alternative names of fields for searches ALT_NAMES = { 'name': SearchAltName( @@ -966,6 +972,7 @@ class TreatmentFile(DashboardFormItem, ClosedItem, DocumentItem, ), } ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES) + ALT_NAMES.update(DocumentItem.ALT_NAMES) DATED_FIELDS = ['exhibition_start_date__lte', 'exhibition_start_date__gte', |