Ejemplo n.º 1
0
 def clean_date_start(self):
     dt = self.cleaned_data['date_start']
     now = datetime.datetime.now()
     if dt <= now:
         raise forms.ValidationError("You can't book a date in the past")
     if (dt - now) > settings.MAX_BOOKING_ADVANCE:
         sec = timeDeltaToSeconds(settings.MAX_BOOKING_ADVANCE)
         raise forms.ValidationError("You can't book more than %s in advance" % duration_human(sec))
     return dt
Ejemplo n.º 2
0
 def clean_date_end(self):
     dt = self.cleaned_data['date_start']
     de = self.cleaned_data['date_end']
     print dt
     print de
     if de < dt:
         raise forms.ValidationError("Are you serious? End time should be after start time")
     if (de - dt) < settings.MIN_BOOKING_TIME:
         sec = timeDeltaToSeconds(settings.MIN_BOOKING_TIME)
         raise forms.ValidationError("Minimun booking time is %s" % duration_human(sec))
     return de
Ejemplo n.º 3
0
 def display_duration(self):
     if self.duration > 0:
         return duration_human(self.duration*60)
     return ''