class NewFormForm(Schema): """NewFormForm is a Schema for validating the data entered at the Add Form page. """ allow_extra_fields = True filter_extra_fields = True pre_validators = [variabledecode.NestedVariables()] transcription = UnicodeString( not_empty=True, messages={'empty': 'Please enter a transcription.'}) phoneticTranscription = UnicodeString() narrowPhoneticTranscription = UnicodeString() morphemeBreak = UnicodeString() grammaticality = UnicodeString() morphemeGloss = UnicodeString() glosses = FirstGlossNotEmpty() comments = UnicodeString() speakerComments = UnicodeString() context = UnicodeString() elicitationMethod = UnicodeString() keywords = ForEach(Keyword()) syntacticCategory = UnicodeString() speaker = UnicodeString() elicitor = UnicodeString() verifier = UnicodeString() source = UnicodeString() dateElicited = DateConverter(month_style='mm/dd/yyyy')
class fields(WidgetsList): title = TextField(validator=NotEmpty) author = TextField(validator=NotEmpty) description = TextArea(attrs=dict(rows=3, cols=25)) date_taken = CalendarDatePicker(validator=DateConverter()) subject_list = ((1, "Philosophy"), (2, "Maths"), (3, "Literature"), (4, "History"), (5, "Politics"), (6, "Sociology")) subject = SingleSelectField(options=subject_list)
class RacingTeamApplnResultsValidator(Schema): name = NotEmpty() eventdate = DateConverter(month_style='iso') eventname = NotEmpty() distance = Number(min=0, max=200) units = OneOf(['miles', 'km']) time = TimeOptHoursConverter() agegrade = Number(min=0, max=100)
class NewFileForm(Schema): """NewFileForm is a Schema for validating the data entered at the Add File page.""" allow_extra_fields = True filter_extra_fields = True dateElicited = DateConverter(month_style='mm/dd/yyyy') description = UnicodeString() speaker = UnicodeString() elicitor = UnicodeString() utteranceType = UnicodeString()
class ApplnValidator(Schema): name = ByteString(not_empty=True) email = Email() dob = DateConverter(month_style='iso') gender = OneOf(['M', 'F']) applntype = OneOf(['new', 'renewal']) race1_name = ByteString(not_empty=True) race1_location = ByteString(not_empty=True) race1_date = DateConverter(month_style='iso') race1_distance = Number(min=0, max=200) race1_units = OneOf(['miles', 'km']) race1_time = TimeOptHoursConverter() race1_resultslink = URL() race2_name = ByteString(not_empty=True) race2_location = ByteString(not_empty=True) race2_date = DateConverter(month_style='iso') race2_distance = Number(min=0, max=200) race2_units = OneOf(['miles', 'km']) race2_time = TimeOptHoursConverter() race2_resultslink = URL()
class NewCollectionForm(Schema): """NewCollectionForm is a Schema for validating the data entered at the Add Collection page.""" allow_extra_fields = True filter_extra_fields = True title = UnicodeString(not_empty=True) url = Regex('[a-zA-Z0-9_/-]+') type = UnicodeString() description = UnicodeString() speaker = UnicodeString() elicitor = UnicodeString() source = UnicodeString() dateElicited = DateConverter(month_style='mm/dd/yyyy') contents = UnicodeString()
def test_date(): date = DateConverter(month_style='dd/mm/yyyy') try: date.to_python('20/12/150') except Invalid, e: assert 'Please enter a four-digit year after 1899' in str(e)
def test_month_style(): date = DateConverter(month_style='dd/mm/yyyy') d = datetime.date(2007,12,20) assert date.to_python('20/12/2007') == d assert date.from_python(d) == '20/12/2007'
class InfoVolunteerValidator(Schema): common_eventdate = DateConverter(month_style='iso') volunteer_hours = Number(min=0, max=200) volunteer_comments = NotEmpty()
class InfoRaceResultValidator(Schema): common_eventdate = DateConverter(month_style='iso') raceresult_distance = Number(min=0, max=200) raceresult_units = OneOf(['miles', 'km']) raceresult_time = TimeOptHoursConverter()
class InfoCommonValidator(Schema): common_name = ByteString(not_empty=True) common_eventname = ByteString(not_empty=True) common_eventdate = DateConverter(month_style='iso') common_infotype = OneOf(['raceresult', 'volunteer'])
class DateRestrictorStruct(Schema): location = UnicodeString() relation = UnicodeString() date = DateConverter(month_style='mm/dd/yyyy')
class UpdateFileFormDM(UpdateFileForm): dateElicited = DateConverter(month_style='dd/mm/yyyy')
class NewCollectionFormDM(NewCollectionForm): dateElicited = DateConverter(month_style='dd/mm/yyyy')
class RacingTeamMembersValidator(Schema): dateofbirth = DateConverter(month_style='iso') gender = OneOf(['M', 'F'])
class AddLuckyNumberForm(Schema): date = DateConverter(month_style='dd/mm/yyyy') number = Int()