From 2e690a6ad366f61796b3c6a3fe0526bd89c485a4 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 7 Apr 2016 00:28:11 +0200 Subject: Context records: search within relations --- archaeological_context_records/forms.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'archaeological_context_records/forms.py') diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py index e9b5994eb..5160c1c51 100644 --- a/archaeological_context_records/forms.py +++ b/archaeological_context_records/forms.py @@ -59,6 +59,9 @@ class RecordSelect(TableSelect): datings__period = forms.ChoiceField(label=_(u"Period"), choices=[]) unit = forms.ChoiceField(label=_(u"Unit type"), choices=[]) parcel = ParcelField(label=_(u"Parcel (section/number)")) + relation_types = forms.MultipleChoiceField( + label=_(u"Search within relations"), choices=[], + widget=forms.CheckboxSelectMultiple) def __init__(self, *args, **kwargs): super(RecordSelect, self).__init__(*args, **kwargs) @@ -66,12 +69,17 @@ class RecordSelect(TableSelect): self.fields['datings__period'].help_text = Period.get_help() self.fields['unit'].choices = models.Unit.get_types() self.fields['unit'].help_text = models.Unit.get_help() + self.fields['relation_types'].choices = models.RelationType.get_types( + empty_first=False) def get_input_ids(self): ids = super(RecordSelect, self).get_input_ids() ids.pop(ids.index('parcel')) ids.append('parcel_0') ids.append('parcel_1') + ids.pop(ids.index('relation_types')) + for idx, c in enumerate(self.fields['relation_types'].choices): + ids.append('relation_types_{}'.format(idx)) return ids -- cgit v1.2.3