diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-03-26 18:39:45 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-03-26 18:39:45 +0200 | 
| commit | c6641be6f54e2aff0a4256e19b9c061cb4f4612b (patch) | |
| tree | c25424d9c4d45131f18dadf261854ffa54e6b631 /archaeological_finds/forms.py | |
| parent | 15611a7231ad6b16a9fb5586d036e3db53b3cc1b (diff) | |
| download | Ishtar-c6641be6f54e2aff0a4256e19b9c061cb4f4612b.tar.bz2 Ishtar-c6641be6f54e2aff0a4256e19b9c061cb4f4612b.zip | |
Finds - discovery date: add a TAQ field (refs #4039) - improve display of discovery date in sheet - better display for textarea field
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) | 
