diff options
Diffstat (limited to 'archaeological_context_records/forms.py')
-rw-r--r-- | archaeological_context_records/forms.py | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py index 0683b695f..f3bbb1b65 100644 --- a/archaeological_context_records/forms.py +++ b/archaeological_context_records/forms.py @@ -30,10 +30,11 @@ from django.utils.translation import ugettext_lazy as _ from ishtar_common.models import valid_id from archaeological_operations.models import Period, Parcel, Operation, \ - ArchaeologicalSite + ArchaeologicalSite, RelationType as OpeRelationType import models from ishtar_common import widgets +from archaeological_operations.widgets import OAWidget from ishtar_common.forms import FinalForm, FormSet, \ reverse_lazy, get_form_selection, TableSelect from ishtar_common.forms_common import get_town_field, SourceSelect @@ -46,6 +47,7 @@ class RecordSelect(TableSelect): parcel__town = get_town_field() if settings.COUNTRY == 'fr': operation__code_patriarche = forms.IntegerField( + widget=OAWidget, label=_(u"Code PATRIARCHE")) operation__year = forms.IntegerField(label=_(u"Operation's year")) operation__operation_code = forms.IntegerField( @@ -56,9 +58,12 @@ class RecordSelect(TableSelect): reverse_lazy('autocomplete-archaeologicalsite'), associated_model=ArchaeologicalSite), validators=[valid_id(ArchaeologicalSite)]) + ope_relation_types = forms.MultipleChoiceField( + label=_(u"Search within operation relations"), choices=[], + widget=forms.CheckboxSelectMultiple) datings__period = forms.ChoiceField(label=_(u"Period"), choices=[]) unit = forms.ChoiceField(label=_(u"Unit type"), choices=[]) - parcel = ParcelField(label=_(u"Parcel (section/number)")) + parcel = ParcelField(label=_(u"Parcel (section/number/public domain)")) relation_types = forms.MultipleChoiceField( label=_(u"Search within relations"), choices=[], widget=forms.CheckboxSelectMultiple) @@ -71,15 +76,21 @@ class RecordSelect(TableSelect): self.fields['unit'].help_text = models.Unit.get_help() self.fields['relation_types'].choices = models.RelationType.get_types( empty_first=False) + self.fields['ope_relation_types'].choices = OpeRelationType.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.append('parcel_2') ids.pop(ids.index('relation_types')) for idx, c in enumerate(self.fields['relation_types'].choices): ids.append('relation_types_{}'.format(idx)) + 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)) return ids @@ -113,10 +124,10 @@ class RecordFormGeneral(forms.Form): validators=[validators.MaxLengthValidator(200)]) description = forms.CharField(label=_(u"Description"), widget=forms.Textarea, required=False) - length = forms.IntegerField(label=_(u"Length (cm)"), required=False) - width = forms.IntegerField(label=_(u"Width (cm)"), required=False) - thickness = forms.IntegerField(label=_(u"Thickness (cm)"), required=False) - depth = forms.IntegerField(label=_(u"Depth (cm)"), required=False) + length = forms.IntegerField(label=_(u"Length (m)"), required=False) + width = forms.IntegerField(label=_(u"Width (m)"), required=False) + thickness = forms.IntegerField(label=_(u"Thickness (m)"), required=False) + depth = forms.IntegerField(label=_(u"Depth (m)"), required=False) unit = forms.ChoiceField(label=_("Unit"), required=False, choices=[]) location = forms.CharField( label=_(u"Location"), widget=forms.Textarea, @@ -148,8 +159,8 @@ class RecordFormGeneral(forms.Form): parcels = sorted(parcels, key=sort) for key, gparcels in groupby(parcels, sort): self.fields['parcel'].choices.append( - (" - ".join(key), [(parcel.pk, parcel.short_label) - for parcel in gparcels]) + (" - ".join([k for k in key if k]), + [(parcel.pk, parcel.short_label) for parcel in gparcels]) ) self.fields['unit'].choices = models.Unit.get_types() self.fields['unit'].help_text = models.Unit.get_help() @@ -230,6 +241,9 @@ class RecordFormInterpretation(forms.Form): form_label = _("Interpretation") associated_models = {'activity': models.ActivityType, 'identification': models.IdentificationType} + datings_comment = forms.CharField( + label=_(u"Comments on dating"), required=False, + widget=forms.Textarea) has_furniture = forms.NullBooleanField(label=_(u"Has furniture?"), required=False) filling = forms.CharField(label=_(u"Filling"), @@ -277,10 +291,16 @@ SourceRecordFormSelection = get_form_selection( class RecordSourceSelect(SourceSelect): - context_record__parcel__town = get_town_field( - label=_(u"Town of the operation")) context_record__operation__year = forms.IntegerField( label=_(u"Year of the operation")) + context_record__operation__operation_code = forms.IntegerField( + label=_(u"Numeric reference")) + if settings.COUNTRY == 'fr': + context_record__operation__code_patriarche = forms.IntegerField( + widget=OAWidget, + label="Code PATRIARCHE") + context_record__parcel__town = get_town_field( + label=_(u"Town of the operation")) context_record__datings__period = forms.ChoiceField( label=_(u"Period of the context record"), choices=[]) context_record__unit = forms.ChoiceField( |