def __call__(self, context):
        """ Look for an enclosing program
            list available languages in it """
        terms = []
        levels = [("basic", _(u"Basic")), ("intermediate", _(u"Intermediate")), ("advanced", _(u"Advanced"))]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
Esempio n. 2
0
 def validate_duration(data):
     ''' Validate provided start and end date'''
     start_date = data.start_date
     end_date = data.end_date
     if start_date or end_date:
         # As it is not required we will only check if
         # any of these fields are provided
         if not (start_date and end_date):
             msg = _(u'Please provide a start and an end date')
             raise InvalidDateRange(msg)
         # Use datetime instead of DateTime
         if isinstance(start_date, DateTime):
             start_date = start_date.asdatetime().date()
         if isinstance(end_date, DateTime):
             end_date = end_date.asdatetime().date()
         # We will have a timedelta object here
         delta = end_date - start_date
         if not(delta.days > -1):
             msg = _(u'End date must not be prior to start date')
             raise InvalidDateRange(msg)
 def validate_duration(data):
     ''' Validate provided start and end date'''
     start_date = data.start_date
     end_date = data.end_date
     if start_date or end_date:
         # As it is not required we will only check if
         # any of these fields are provided
         if not (start_date and end_date):
             msg = _(u'Please provide a start and an end date')
             raise InvalidDateRange(msg)
         # Use datetime instead of DateTime
         if isinstance(start_date, DateTime):
             start_date = start_date.asdatetime()
         if isinstance(end_date, DateTime):
             end_date = end_date.asdatetime()
         # We will have a timedelta object here
         delta = end_date - start_date
         if not(delta.days > -1 and delta.seconds >= 300):
             msg = _(u'End date must be in the future of start date and '
                     u'duration of session should be at least 5 minutes.')
             raise InvalidDateRange(msg)