diff options
| -rw-r--r-- | CHANGES.md | 7 | ||||
| -rw-r--r-- | archaeological_warehouse/forms.py | 17 | ||||
| -rw-r--r-- | archaeological_warehouse/models.py | 25 | ||||
| -rw-r--r-- | ishtar_common/forms_common.py | 2 | 
4 files changed, 46 insertions, 5 deletions
diff --git a/CHANGES.md b/CHANGES.md index 13f0f611e..b3907be7f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,13 @@ v3.0.4 - 2020-XX-XX    - operation: bulk update - operator field    - site: add bulk update form (towns field)    - find: bulk update - appraisal date and treatment emergency fields +- Search - criteria: +  - Containers: +    - find ID, label +    - operation: town, scientist +  - Warehouse: +    - town +  v3.0.3 - 2020-02-24  ------------------- diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index b950a5d3c..867761047 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -27,7 +27,7 @@ from django.forms.formsets import formset_factory  from ishtar_common.utils import ugettext_lazy as _  from ishtar_common.models import Person, valid_id, Town, \ -    SpatialReferenceSystem, Organization, valid_ids +    SpatialReferenceSystem, Organization, valid_ids, person_type_pks_lazy  from archaeological_operations.models import ArchaeologicalSite  from archaeological_context_records.models import ContextRecord  from archaeological_finds.models import TreatmentType, FindBasket, \ @@ -99,8 +99,9 @@ class WarehouseSelect(CustomForm, TableSelect):          label=_(u"Full text search"), widget=widgets.SearchWidget(              'archaeological-warehouse', 'warehouse'          )) -    name = forms.CharField(label=_(u"Name")) -    warehouse_type = forms.ChoiceField(label=_(u"Warehouse type"), choices=[]) +    name = forms.CharField(label=_("Name")) +    warehouse_type = forms.ChoiceField(label=_("Warehouse type"), choices=[]) +    town = get_town_field(label=_("Town"))      def __init__(self, *args, **kwargs):          super(WarehouseSelect, self).__init__(*args, **kwargs) @@ -390,14 +391,22 @@ class ContainerSelect(HistorySelect):      archaeological_sites_context_record_name = forms.CharField(          label=_(u"Archaeological site name (attached to the context record)")      ) -    code_patriarche = forms.IntegerField(label=_(u"Code PATRIARCHE"), +    code_patriarche = forms.IntegerField(label=_("Operation - Code PATRIARCHE"),                                           widget=OAWidget) +    operation_town = get_town_field(label=_("Operation - town")) +    operation_scientist = forms.IntegerField( +        widget=widgets.JQueryAutoComplete( +            reverse_lazy('autocomplete-person-permissive'), +            associated_model=Person), +        label=_("Operation - Scientist"))      context_record = forms.IntegerField(          label=_("Context record"),          widget=widgets.JQueryAutoComplete(              reverse_lazy('autocomplete-contextrecord'),              associated_model=ContextRecord),          validators=[valid_id(ContextRecord)]) +    find_label = forms.CharField(label=_("Find - Label")) +    find_denomination = forms.CharField(label=_("Find - Denomination"))      description = forms.CharField(label=_(u"Find - Description"))      material_types = forms.IntegerField(          label=_(u"Material type"), diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 89c208df8..75a3deda0 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -83,6 +83,11 @@ class Warehouse(Address, DocumentItem, GeoItem, QRCodeItem, DashboardFormItem,              pgettext_lazy("key for text search", "type"),              'warehouse_type__label__iexact'          ), +        'town': +            SearchAltName( +                pgettext_lazy("key for text search", "town"), +                'precise_town__cached_label__iexact' +            ),      }      GEO_LABEL = "name"      DOWN_MODEL_UPDATE = ["containers"] @@ -496,6 +501,18 @@ class Container(DocumentItem, LightHistorizedItem, QRCodeItem, GeoItem,              pgettext_lazy("key for text search", "comment"),              'comment__iexact'          ), +        'operation_town': +            SearchAltName( +                pgettext_lazy("key for text search", "operation-town"), +                'finds__base_finds__context_record__operation__' +                'towns__cached_label__iexact' +            ), +        'operation_scientist': +            SearchAltName( +                pgettext_lazy("key for text search", "operation-scientist"), +                'finds__base_finds__context_record__operation__' +                'scientist__cached_label__iexact' +            ),          'code_patriarche':              SearchAltName(                  pgettext_lazy("key for text search", "code-patriarche"), @@ -527,6 +544,14 @@ class Container(DocumentItem, LightHistorizedItem, QRCodeItem, GeoItem,              SearchAltName(                  pgettext_lazy("key for text search", "context-record"),                  'finds__base_finds__context_record__cached_label__icontains'), +        'find_label': +            SearchAltName( +                pgettext_lazy("key for text search", "find-label"), +                'finds__label__icontains'), +        'find_denomination': +            SearchAltName( +                pgettext_lazy("key for text search", "find-denomination"), +                'finds__denomination__icontains'),          'material_types':              SearchAltName(                  pgettext_lazy("key for text search", "material"), diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 5d97550ab..2b52f0919 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -57,7 +57,7 @@ from archaeological_finds.models import Find, FindBasket  from archaeological_warehouse.models import Container -def get_town_field(label=_(u"Town"), required=True): +def get_town_field(label=_("Town"), required=True):      help_text = _(          u"<p>Type name, department code of the "          u"town you would like to select. The search is insensitive to case."  | 
