From 9457a4e43f67e5afc612cbfecac38e1e11522534 Mon Sep 17 00:00:00 2001 From: Serghei MIHAI Date: Tue, 19 Aug 2014 15:30:10 +0200 Subject: [PATCH] agenda: when adding events of type COURRIEL or TELEPHONE the start time and duration are taken in account and default to 8h and 10 minutes if not defined Closes #5015 --- calebasse/agenda/forms.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/calebasse/agenda/forms.py b/calebasse/agenda/forms.py index ba46178..82de187 100644 --- a/calebasse/agenda/forms.py +++ b/calebasse/agenda/forms.py @@ -67,18 +67,16 @@ class NewAppointmentForm(BaseForm): .order_by('name') def clean_time(self): + if self.cleaned_data['time']: + return self.cleaned_data['time'] + act_type = self.data.get('act_type') # act type is available as raw data from the post request if act_type in self.special_types: return time(8, 0) - if self.cleaned_data['time']: - return self.cleaned_data['time'] raise forms.ValidationError(_(u'This field is required.')) def clean_duration(self): - act_type = self.data.get('act_type') - if act_type in self.special_types: - return 10 if self.cleaned_data['duration']: duration = self.cleaned_data['duration'] try: @@ -88,6 +86,10 @@ class NewAppointmentForm(BaseForm): return duration except ValueError: raise forms.ValidationError(u'Le champ doit contenir uniquement des chiffres') + + act_type = self.data.get('act_type') + if act_type in self.special_types: + return 10 raise forms.ValidationError(_(u'This field is required.')) def clean_patient(self): -- 2.1.0