diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-07-10 18:36:48 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-07-10 18:36:48 +0200 |
commit | 7dc79581218a205fb5b80ea6db306b77b9bd529b (patch) | |
tree | be8d4564e68a0bf65a2b4f0136621d67f2acf62a /ishtar/ishtar_base/forms_operations.py | |
parent | 571aa094f71d152df9a8ce60cd41a0bcad64bd0b (diff) | |
download | Ishtar-7dc79581218a205fb5b80ea6db306b77b9bd529b.tar.bz2 Ishtar-7dc79581218a205fb5b80ea6db306b77b9bd529b.zip |
Disambiguation of closing date and end of excavation work (closes #526)
Diffstat (limited to 'ishtar/ishtar_base/forms_operations.py')
-rw-r--r-- | ishtar/ishtar_base/forms_operations.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ishtar/ishtar_base/forms_operations.py b/ishtar/ishtar_base/forms_operations.py index 6e6cdc03e..5ed882530 100644 --- a/ishtar/ishtar_base/forms_operations.py +++ b/ishtar/ishtar_base/forms_operations.py @@ -232,6 +232,8 @@ class OperationFormGeneral(forms.Form): choices=[]) start_date = forms.DateField(label=_(u"Start date"), required=False, widget=widgets.JQueryDate) + excavation_end_date = forms.DateField(label=_(u"Excavation end date"), + required=False, widget=widgets.JQueryDate) surface = forms.IntegerField(required=False, widget=widgets.AreaWidget, label=_(u"Total surface (m²)"), validators=[validators.MinValueValidator(0), @@ -248,6 +250,20 @@ class OperationFormGeneral(forms.Form): self.fields['operation_type'].choices = models.OperationType.get_types() self.fields['operation_type'].help_text = models.OperationType.get_help() + def clean(self): + # verify the logic between start date and excavation end date + if not self.cleaned_data['excavation_end_date']: + return self.cleaned_data + if self.cleaned_data['excavation_end_date'] and \ + not self.cleaned_data['start_date']: + raise forms.ValidationError(_(u"If you want to set an excavation \ +end date you have to provide a start date.")) + if self.cleaned_data['excavation_end_date'] < \ + self.cleaned_data['start_date']: + raise forms.ValidationError(_(u"The excavation end date cannot be \ +before the start date.")) + return self.cleaned_data + class OperationFormReference(forms.Form): form_label = _("References") associated_models = {'in_charge':models.Person, @@ -470,7 +486,7 @@ class OperationDateFormSelection(forms.Form): class OperationClosingWizard(ClosingWizard): model = models.Operation fields = ['year', 'operation_code', 'operation_type', 'associated_file', - 'in_charge', 'start_date', 'end_date', 'comment', 'towns', 'remains'] +'in_charge', 'start_date', 'excavation_end_date', 'comment', 'towns', 'remains'] class FinalOperationClosingForm(FinalForm): confirm_msg = " " |