Esempio n. 1
0
 def validateObject(self, obj):
     errors = super(AddTermFormValidator, self).validateObject(obj)
     try:
         dr = DateRange(obj.first, obj.last)
         try:
             validateTermsForOverlap(self.view.context, dr, None)
         except TermOverlapError, e:
             errors += (e, )
     except ValueError, e:
         errors += (Invalid(_("Term must begin before it ends.")), )
Esempio n. 2
0
 def validate(self, value):
     # XXX: hack to display the overlap error next to the widget!
     super(FlourishOverlapValidator, self).validate(value)
     last_widget = self.view.widgets['last']
     last_value = self.request.get(last_widget.name)
     try:
         last_value = last_widget._toFieldValue(last_value)
     except:
         return
     try:
         dr = DateRange(value, last_value)
     except:
         raise FlourishInvalidDateRangeError()
     try:
         validateTermsForOverlap(self.container, dr, self.term)
     except TermOverlapError, e:
         raise FlourishOverlapError()