diff options
Diffstat (limited to 'archaeological_finds/forms.py')
| -rw-r--r-- | archaeological_finds/forms.py | 23 | 
1 files changed, 21 insertions, 2 deletions
| diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 04001366e..6a72aa590 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -142,8 +142,8 @@ class FindForm(CustomForm, ManageOldType):                           'get_first_base_find__spatial_reference_system':                           SpatialReferenceSystem}      HEADERS = {} -      HEADERS['label'] = FormHeader(_(u"Identification")) +      label = forms.CharField(          label=_(u"Free ID"),          validators=[validators.MaxLengthValidator(60)]) @@ -158,7 +158,10 @@ class FindForm(CustomForm, ManageOldType):      description = forms.CharField(label=_(u"Description"),                                    widget=forms.Textarea, required=False)      get_first_base_find__discovery_date = forms.DateField( -        label=_(u"Discovery date"), widget=DatePicker, required=False) +        label=_(u"Discovery date (exact or TPQ)"), widget=DatePicker, +        required=False) +    get_first_base_find__discovery_date_taq = forms.DateField( +        label=_(u"Discovery date (TAQ)"), widget=DatePicker, required=False)      get_first_base_find__batch = forms.ChoiceField(          label=_(u"Batch/object"), choices=[],          required=False) @@ -254,6 +257,22 @@ class FindForm(CustomForm, ManageOldType):          self.fields['checked'].choices = models.CHECK_CHOICES      def clean(self): +        taq = self.cleaned_data.get('get_first_base_find__discovery_date_taq', +                                    None) +        tpq = self.cleaned_data.get('get_first_base_find__discovery_date', +                                    None) +        if taq and not tpq: +            raise forms.ValidationError( +                unicode(_( +                    u"Discovery date: if a TAQ date is provided a TPQ date has " +                    u"to be informed. If you have a precise date fill only the " +                    u"TPQ - discovery date field.")) +            ) +        elif tpq and taq and taq < tpq: +            raise forms.ValidationError( +                unicode(_(u"Discovery date: TAQ date must be older than TPQ " +                          u"date."))) +          if not get_current_profile().mapping:              return self.cleaned_data          x = self.cleaned_data.get('get_first_base_find__x', None) | 
