Projet

Général

Profil

0001-agenda-when-adding-events-of-type-COURRIEL-or-TELEPH.patch

Serghei Mihai (congés, retour 15/05), 19 août 2014 15:33

Télécharger (1,81 ko)

Voir les différences:

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(-)
calebasse/agenda/forms.py
67 67
                    .order_by('name')
68 68

  
69 69
    def clean_time(self):
70
        if self.cleaned_data['time']:
71
            return self.cleaned_data['time']
72

  
70 73
        act_type = self.data.get('act_type')
71 74
        # act type is available as raw data from the post request
72 75
        if act_type in self.special_types:
73 76
            return time(8, 0)
74
        if self.cleaned_data['time']:
75
            return self.cleaned_data['time']
76 77
        raise forms.ValidationError(_(u'This field is required.'))
77 78

  
78 79
    def clean_duration(self):
79
        act_type = self.data.get('act_type')
80
        if act_type in self.special_types:
81
            return 10
82 80
        if self.cleaned_data['duration']:
83 81
            duration = self.cleaned_data['duration']
84 82
            try:
......
88 86
                return duration
89 87
            except ValueError:
90 88
                raise forms.ValidationError(u'Le champ doit contenir uniquement des chiffres')
89

  
90
        act_type = self.data.get('act_type')
91
        if act_type in self.special_types:
92
            return 10
91 93
        raise forms.ValidationError(_(u'This field is required.'))
92 94

  
93 95
    def clean_patient(self):
94
-