diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-10-13 13:07:38 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-07-08 09:58:48 +0200 | 
| commit | abb1870fd12ec1f7ea0a7fd75d5dd33a03be3d5a (patch) | |
| tree | 9031f7cbb546284f0550c8c1cd292e8833d94155 | |
| parent | de1e0fcef9b18c5df11e334f3565d20469887ec0 (diff) | |
| download | Ishtar-abb1870fd12ec1f7ea0a7fd75d5dd33a03be3d5a.tar.bz2 Ishtar-abb1870fd12ec1f7ea0a7fd75d5dd33a03be3d5a.zip  | |
Find/context record search: change search order, terms, fix search field
| -rw-r--r-- | archaeological_context_records/models.py | 2 | ||||
| -rw-r--r-- | archaeological_finds/forms.py | 42 | ||||
| -rw-r--r-- | archaeological_finds/models_finds.py | 8 | ||||
| -rw-r--r-- | archaeological_finds/tests.py | 2 | 
4 files changed, 32 insertions, 22 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 9dd9956f1..f620b1ff1 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -543,7 +543,7 @@ class ContextRecord(              "cr_relation_types",          ),          "excavation_technic": SearchAltName( -            pgettext_lazy("key for text search", "excavation-technic"), +            pgettext_lazy("key for text search", "excavation-technique"),              "excavation_technic__label__iexact",          ),      } diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index a99d6fed4..da394c1ef 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -62,7 +62,7 @@ from ishtar_common.forms_common import get_town_field  from archaeological_context_records.forms import PeriodSelect  from ishtar_common.models import valid_id, valid_ids, get_current_profile, \ -    SpatialReferenceSystem, Area, OperationType, IshtarUser +    SpatialReferenceSystem, Area, OperationType, IshtarUser, Person, person_type_pks_lazy  from ishtar_common.utils import convert_coordinates_to_point  __all__ = [ @@ -1016,23 +1016,6 @@ class FindSelect(DocumentItemSelect, PeriodSelect):          label=_("Full text search"), widget=widgets.SearchWidget(              'archaeological-finds', 'find'          )) -    base_finds__context_record__operation__address = forms.CharField(label=_("Address")) -    base_finds__context_record__operation__person_in_charge = forms.IntegerField( -        label=_("Person in charge"), -        widget=widgets.JQueryAutoComplete( -            reverse_lazy("autocomplete-person") -        ) -    ) -    base_finds__context_record__operation__operator = forms.IntegerField( -        label=_("Operator"), -        widget=widgets.JQueryAutoComplete( -            reverse_lazy("autocomplete-organization") -        ) -    ) -    base_finds__context_record__operation__common_name = forms.CharField( -        label=_("Operation name"), -        max_length=30 -    )      label = forms.CharField(label=_("Free ID"))      denomination = forms.CharField(label=_("Denomination"))      previous_id = forms.CharField(label=_("Previous ID")) @@ -1059,6 +1042,29 @@ class FindSelect(DocumentItemSelect, PeriodSelect):      base_finds__context_record__operation__operation_type = forms.ChoiceField(          label=_("Operation type"), choices=[]      ) +    base_finds__context_record__operation__address = forms.CharField(label=_("Operation - Address / Locality")) +    base_finds__context_record__operation__in_charge = forms.IntegerField( +        label=_("Operation - In charge"), +        widget=widgets.JQueryAutoComplete( +            reverse_lazy("autocomplete-person") +        ) +    ) +    base_finds__context_record__operation__scientist = forms.IntegerField( +        widget=widgets.JQueryAutoComplete( +            reverse_lazy( +                'autocomplete-person-permissive', +                args=[person_type_pks_lazy(['sra_agent', 'head_scientist'])]), +            associated_model=Person), +        label=_("Operation - Scientist in charge")) +    base_finds__context_record__operation__operator = forms.IntegerField( +        label=_("Operation - Operator"), +        widget=widgets.JQueryAutoComplete( +            reverse_lazy("autocomplete-organization") +        ) +    ) +    base_finds__context_record__operation__common_name = forms.CharField( +        label=_("Operation - Name"), +    )      base_finds__context_record__town__areas = forms.ChoiceField(          label=_("Areas"), choices=[]      ) diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index aeb4aaf90..b909720eb 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1584,16 +1584,20 @@ class Find(              "base_finds__context_record__operation__address__iexact",          ),          "base_finds__context_record__operation__in_charge": SearchAltName( -            pgettext_lazy("key for text search", "person-in-charge"), +            pgettext_lazy("key for text search", "in-charge"),              "base_finds__context_record__operation__in_charge__cached_label__iexact",          ), +        "base_finds__context_record__operation__scientist": SearchAltName( +            pgettext_lazy("key for text search", "scientist"), +            "base_finds__context_record__operation__scientist__cached_label__iexact", +        ),          "base_finds__context_record__operation__operator": SearchAltName(              pgettext_lazy("key for text search", "operator"),              "base_finds__context_record__operation__operator__cached_label__iexact",          ),          "base_finds__context_record__operation__common_name": SearchAltName(              pgettext_lazy("key for text search", "operation-name"), -            "base_finds__context_record__operation__common_name__icontains", +            "base_finds__context_record__operation__common_name__iexact",          ),      }      ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES) diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index c31ebec26..1c42c28ba 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -1338,7 +1338,7 @@ class FindSearchTest(FindInit, TestCase, SearchText):          c = Client()          c.login(username=self.username, password=self.password) -        key = str(pgettext_lazy("key for text search", "person-in-charge")) +        key = str(pgettext_lazy("key for text search", "in-charge"))          result = [              ('{}="{}"'.format(key, "HISNAME Michel"), 1)          ]  | 
