summaryrefslogtreecommitdiff
path: root/archaeological_context_records/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records/forms.py')
-rw-r--r--archaeological_context_records/forms.py41
1 files changed, 14 insertions, 27 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index 2fd3fee9a..b659c64f1 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -57,7 +57,9 @@ class OperationFormSelection(CustomForm, forms.Form):
validators=[valid_id(Operation)])
-class RecordSelect(CustomForm, TableSelect):
+class RecordSelect(CustomForm, TableSelect): # OK
+ _model = models.ContextRecord
+
form_admin_name = _(u"Context record - 001 - Search")
form_slug = "contextrecord-001-search"
search_vector = forms.CharField(
@@ -80,38 +82,23 @@ class RecordSelect(CustomForm, TableSelect):
reverse_lazy('autocomplete-archaeologicalsite'),
associated_model=ArchaeologicalSite),
validators=[valid_id(ArchaeologicalSite)])
- ope_relation_types = forms.MultipleChoiceField(
- label=_(u"Search within related operations"), choices=[],
- widget=forms.CheckboxSelectMultiple)
+ ope_relation_types = forms.ChoiceField(
+ label=_(u"Search within related operations"), choices=[])
datings__period = forms.ChoiceField(label=_(u"Period"), choices=[])
unit = forms.ChoiceField(label=_(u"Unit type"), choices=[])
- parcel = ParcelField(label=_(u"Parcel (section/number/public domain)"))
- cr_relation_types = forms.MultipleChoiceField(
- label=_(u"Search within relations"), choices=[],
- widget=forms.CheckboxSelectMultiple)
+ parcel = forms.CharField(label=_(u"Parcel"))
+ cr_relation_types = forms.ChoiceField(
+ label=_(u"Search within relations"), choices=[])
- def __init__(self, *args, **kwargs):
- super(RecordSelect, self).__init__(*args, **kwargs)
- if 'datings__period' in self.fields:
- self.fields['datings__period'].choices = Period.get_types()
- self.fields['datings__period'].help_text = Period.get_help()
- if 'unit' in self.fields:
- self.fields['unit'].choices = models.Unit.get_types()
- self.fields['unit'].help_text = models.Unit.get_help()
- if 'cr_relation_types' in self.fields:
- self.fields['cr_relation_types'].choices = \
- models.RelationType.get_types(empty_first=False)
- if 'ope_relation_types' in self.fields:
- self.fields['ope_relation_types'].choices = \
- OpeRelationType.get_types(empty_first=False)
+ TYPES = [
+ FieldType('datings__period', Period),
+ FieldType('unit', models.Unit),
+ FieldType('cr_relation_types', models.RelationType),
+ FieldType('ope_relation_types', OpeRelationType),
+ ]
def get_input_ids(self):
ids = super(RecordSelect, self).get_input_ids()
- if 'parcel' in ids:
- ids.pop(ids.index('parcel'))
- ids.append('parcel_0')
- ids.append('parcel_1')
- ids.append('parcel_2')
if 'cr_relation_types' in ids:
ids.pop(ids.index('cr_relation_types'))
for idx, c in enumerate(self.fields['cr_relation_types'].choices):