diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-08 17:15:26 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-13 18:26:03 +0200 |
commit | fccd2510276e510132d121cd88e76d62b1899122 (patch) | |
tree | 7b6e4f62216cf952b98abc710bba2ebef6b93c7e /archaeological_operations | |
parent | 15e4d32a3220f0f0f4de43f0217b893da862cc4a (diff) | |
download | Ishtar-fccd2510276e510132d121cd88e76d62b1899122.tar.bz2 Ishtar-fccd2510276e510132d121cd88e76d62b1899122.zip |
Manage relation types in searches
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/forms.py | 15 | ||||
-rw-r--r-- | archaeological_operations/models.py | 26 |
2 files changed, 26 insertions, 15 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 866700871..63b350f28 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -524,9 +524,8 @@ class OperationSelect(TableSelect): start_after = DateField(label=_(u"Started after")) end_before = DateField(label=_(u"Ended before")) end_after = DateField(label=_(u"Ended after")) - relation_types = forms.MultipleChoiceField( - label=_(u"Search within relations"), choices=[], - widget=forms.CheckboxSelectMultiple) + relation_types = forms.ChoiceField( + label=_(u"Search within relations"), choices=[]) comment = forms.CharField(label=_(u"Comment"), max_length=500) abstract = forms.CharField(label=_(u"Abstract (full text search)")) scientific_documentation_comment = forms.CharField( @@ -594,15 +593,7 @@ class OperationSelect(TableSelect): k = 'towns__numero_insee__startswith' self.fields[k].choices = [ ('', '--')] + list(settings.ISHTAR_DPTS) - self.fields['relation_types'].choices = models.RelationType.get_types( - empty_first=False) - - def get_input_ids(self): - ids = super(OperationSelect, self).get_input_ids() - ids.pop(ids.index('relation_types')) - for idx, c in enumerate(self.fields['relation_types'].choices): - ids.append('relation_types_{}'.format(idx)) - return ids + self.fields['relation_types'].choices = models.RelationType.get_types() class OperationFormSelection(IshtarForm): diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index dd3302251..6f083fe7f 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -410,14 +410,34 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, pgettext_lazy(TXT_SEARCH_COMMENT, u"operator"), 'operator__cached_label__iexact' ), + 'remains': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"remain"), + 'remains__pk' + ), 'periods': ( pgettext_lazy(TXT_SEARCH_COMMENT, u"period"), 'periods__pk' ), - 'remains': ( - pgettext_lazy(TXT_SEARCH_COMMENT, u"remain"), - 'remains__pk' + 'start_before': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"start-before"), + 'start_date__lte' + ), + 'start_after': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"start-after"), + 'start_date__gte' + ), + 'end_before': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"end-before"), + 'excavation_end_date__lte' ), + 'end_after': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"end-after"), + 'excavation_end_date__gte' + ), + 'relation_types': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"relation-types"), + 'relation_types' + ) } for v in ALT_NAMES.values(): EXTRA_REQUEST_KEYS[v[0]] = v[1] |