diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-05-10 19:20:39 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-05-10 19:20:39 +0200 |
commit | 9efeba22bcdf2270496fb8d305ac07a9abf3a2c1 (patch) | |
tree | b8545c31c4134d581696b9ffa18bddaf11a0348c | |
parent | 332664ff6a380e7da6bbcf6219aa29fb75fd741d (diff) | |
download | Ishtar-9efeba22bcdf2270496fb8d305ac07a9abf3a2c1.tar.bz2 Ishtar-9efeba22bcdf2270496fb8d305ac07a9abf3a2c1.zip |
Find search: search by context records (and within relations)
-rw-r--r-- | archaeological_context_records/models.py | 3 | ||||
-rw-r--r-- | archaeological_finds/forms.py | 16 | ||||
-rw-r--r-- | archaeological_finds/models_finds.py | 5 |
3 files changed, 21 insertions, 3 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index bb3afc899..855ea7d5c 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -202,7 +202,8 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms, 'archaeological_sites': 'operation__archaeological_sites__pk', 'cached_label': 'cached_label__icontains', } - RELATION_TYPES_PREFIX = {'ope_relation_types': 'operation__'} + RELATION_TYPES_PREFIX = {'ope_relation_types': 'operation__', + 'cr_relation_types': ''} RELATIVE_SESSION_NAMES = [ ('operation', 'operation__pk'), ('file', 'operation__associated_file__pk')] diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index ee010094b..2e7cc75f5 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -36,7 +36,7 @@ from ishtar_common.models import valid_id, valid_ids, get_current_profile, \ from archaeological_operations.models import Period, ArchaeologicalSite, \ RelationType as OpeRelationType from archaeological_context_records.models import DatingType, DatingQuality, \ - ContextRecord + ContextRecord, RelationType as CRRelationType import models from ishtar_common.forms import FormSet, FloatField, \ @@ -361,9 +361,18 @@ class FindSelect(TableSelect): reverse_lazy('autocomplete-archaeologicalsite'), associated_model=ArchaeologicalSite), validators=[valid_id(ArchaeologicalSite)]) + base_finds__context_record = forms.IntegerField( + label=_("Context record"), + widget=widgets.JQueryAutoComplete( + reverse_lazy('autocomplete-contextrecord'), + associated_model=ContextRecord), + validators=[valid_id(ContextRecord)]) ope_relation_types = forms.MultipleChoiceField( label=_(u"Search within related operations"), choices=[], widget=widgets.CheckboxSelectMultiple) + cr_relation_types = forms.MultipleChoiceField( + label=_(u"Search within related context records"), choices=[], + widget=widgets.CheckboxSelectMultiple) datings__period = forms.ChoiceField(label=_(u"Period"), choices=[]) material_types = forms.ChoiceField(label=_(u"Material type"), choices=[]) object_types = forms.ChoiceField(label=_(u"Object type"), choices=[]) @@ -417,12 +426,17 @@ class FindSelect(TableSelect): models.RemarkabilityType.get_help() self.fields['ope_relation_types'].choices = OpeRelationType.get_types( empty_first=False) + self.fields['cr_relation_types'].choices = CRRelationType.get_types( + empty_first=False) def get_input_ids(self): ids = super(FindSelect, self).get_input_ids() ids.pop(ids.index('ope_relation_types')) for idx, c in enumerate(self.fields['ope_relation_types'].choices): ids.append('ope_relation_types_{}'.format(idx)) + ids.pop(ids.index('cr_relation_types')) + for idx, c in enumerate(self.fields['cr_relation_types'].choices): + ids.append('cr_relation_types_{}'.format(idx)) return ids diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index d33933264..1b4125e80 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -551,7 +551,10 @@ class Find(ValueGetter, BaseHistorizedItem, ImageModel, OwnPerms, REVERSED_BOOL_FIELDS = ['image__isnull'] RELATION_TYPES_PREFIX = { 'ope_relation_types': - 'base_finds__context_record__operation__'} + 'base_finds__context_record__operation__', + 'cr_relation_types': + 'base_finds__context_record__', + } RELATIVE_SESSION_NAMES = [ ('contextrecord', 'base_finds__context_record__pk'), ('operation', 'base_finds__context_record__operation__pk'), |