class SchoolVOBranch(MappingSchema): address = general_rules.Address() avg_education_hours_per_student = AverageEducationHours() avg_education_hours_per_student_url = SchemaNode(String(), validator=url) board = SchemaNode(String(), validator=Length(min=3, max=100)) board_id = general_rules.board_id branch_id = general_rules.branch_id brin = general_rules.brin building_img_url = SchemaNode(String(), validator=url) costs = Costs() costs_url = SchemaNode(String(), validator=url) denomination = general_rules.denomination education_structures = general_rules.EducationStructures() email = SchemaNode(String(), validator=Email()) logo_img_url = SchemaNode(String(), validator=url) municipality = general_rules.municipality municipality_id = general_rules.municipality_code name = general_rules.name parent_satisfaction = Satisfactions() parent_satisfaction_url = SchemaNode(String(), validator=url) phone = general_rules.phone profile = SchemaNode(String(), validator=Length(min=3, max=500)) province = general_rules.province schoolkompas_status_id = SchemaNode(Int(), validator=Range(min=0,\ max=1000)) schoolvo_code = SchemaNode(String(), validator=Length(min=14, max=14)) student_satisfaction = Satisfactions() student_satisfaction_url = SchemaNode(String(), validator=url) website = general_rules.website
class OrganizationInfoSchema(MappingSchema): """Data structure for organizational information.""" name = SingleLine(missing=drop) validator = OneOf([ 'registered_nonprofit', 'planned_nonprofit', 'support_needed', 'other', ]) city = SingleLine(missing=drop) country = ISOCountryCode(missing=drop) help_request = Text(validator=Length(max=300)) registration_date = DateTime(missing=drop, default=None) website = URL(missing=drop) status = OrganizationStatusEnum(missing=required) status_other = Text(validator=Length(max=300)) def validator(self, node, value): """Extra validation depending on the status of the organisation. Make `status_other` required if `status` == `other` and `help_request` required if `status` == `support_needed`. """ status = value.get('status', None) if status == 'support_needed': if not value.get('help_request', None): help_request = node['help_request'] raise Invalid(help_request, msg='Required iff status == support_needed') elif status == 'other': if not value.get('status_other', None): status_other = node['status_other'] raise Invalid(status_other, msg='Required iff status == other')
class OrganizationInfoSchema(MappingSchema): """Data structure for organizational information.""" name = SingleLine() country = ISOCountryCode() status = StatusEnum() status_other = Text(validator=Length(max=500)) """Custom description for status == other.""" website = URL() planned_date = DateTime(missing=drop, default=None) help_request = Text(validator=Length(max=500)) def validator(self, node, value): """Make `status_other` required if `status` == `other`.""" status = value.get('status', None) if status == 'other': if not value.get('status_other', None): status_other = node['status_other'] raise Invalid(status_other, msg='Required iff status == other') else: # TODO: Allow multiple errors at the same time name = node['name'] if not value.get('name', None): raise Invalid(name, msg='Required iff status != other') country = node['country'] if not value.get('country', None): raise Invalid(country, msg='Required iff status != other')
class ArgumentSchema(Schema): title = string_property(title=_('title'), validator=Length(min=5, max=80)) abstract = string_property(title=_('abstract'), validator=Length(min=5, max=140)) details = string_property(title=_('details'), validator=Length(min=10, max=4096), missing='')
class CurrentRating(MappingSchema): # education_structure = None # TODO owinsp_id = SchemaNode(Int(), validator=Range(min=0)) owinsp_url = general_rules.url() rating = SchemaNode(String(), validator=Length(min=4, max=20)) rating_excerpt = SchemaNode(String(), validator=Length(min=4, max=500)) rating_valid_since = general_rules.publication_date()
class ArgumentSchema(Schema): title = string_property(title=_('title'), validator=Length(min=5, max=TITLE_MAXLENGTH)) abstract = string_property(title=_('abstract'), validator=Length(min=5, max=ABSTRACT_MAXLENGTH)) details = string_property(title=_('details'), validator=Length(min=10, max=4096), missing='')
class AccountRegister(MappingSchema): name = SchemaNode(String(), validator=Regex(REGISTER_NAME_RE)) fullname = SchemaNode(String()) email = SchemaNode(String(), validator=Email()) public_email = SchemaNode(Boolean(), missing=False) password1 = SchemaNode(String(), validator=Length(min=4)) password2 = SchemaNode(String(), validator=Length(min=4)) terms = SchemaNode(Boolean())
class DepartmentSchema(Schema): name = string_property(title=_('name'), validator=Length(min=3, max=255)) description = string_property(title=_('description'), validator=Length(min=10, max=2000), missing='') exporter_settings = json_property(title=_('exporter_settings'), missing={}) voting_module_settings = json_property(title=_('voting_module_settings'), missing={})
class PropositionTypeSchema(Schema): name = string_property(title=_('name'), validator=Length(max=64)) abbreviation = string_property(title=_('abbreviation'), validator=Length(max=3)) description = string_property(title=_('description'), validator=Length(min=10, max=4000), missing='') policy_id = int_property(title=_('policy'))
class Address(MappingSchema): street = SchemaNode(String(), validator=Length(min=4, max=300)) city = city zip_code = SchemaNode(String(), validator=Length(min=6, max=6)) geo_location = Coordinates() geo_viewport = Viewport() formatted_address = SchemaNode(String(), validator=Length(min=3, max=300)) address_components = AddressComponents()
class VotingPhaseTypeSchema(Schema): name = string_property(title=_('name'), validator=Length(min=3, max=255)) abbreviation = string_property(title=_('abbreviation'), validator=Length(max=6)) secret_voting_possible = bool_property(title=_('secret_voting_possible')) voting_type = enum_property(VotingType, title=_('voting_type')) description = string_property(title=_('description'), validator=Length(min=10, max=2000), missing='')
class MailCreateSchema(MappingSchema): subject = SchemaNode(String(), validator=Length(0, 255), missing=drop) content = SchemaNode(String()) name = SchemaNode(String(), validator=Length(0, 255), missing=drop) address = SchemaNode( String(), validator=All(Email(), Length(0, 255)), missing=drop, )
class StudentByStructure(MappingSchema): department = SchemaNode(String(), validator=Length(min=3, max=300)) education_name = SchemaNode(String(), validator=Length(min=3, max=300)) education_structure = general_rules.education_structure elementcode = SchemaNode(Int(), validator=Range(min=0)) lwoo = SchemaNode(Boolean()) vmbo_sector = SchemaNode(String(), validator=Length(min=3, max=300)) year_1 = StudentsEnrolledInStructure() year_2 = StudentsEnrolledInStructure() year_3 = StudentsEnrolledInStructure() year_4 = StudentsEnrolledInStructure() year_5 = StudentsEnrolledInStructure() year_6 = StudentsEnrolledInStructure()
class PropositionSchema(Schema): title = string_property(title=_('title'), validator=Length(min=5, max=255)) content = string_property(title=_('content'), validator=Length(min=10, max=100_000)) motivation = string_property(title=_('motivation'), missing='', validator=Length(max=100_000)) tags = set_property(title=_('tags'), missing=tuple()) abstract = string_property(title=_('abstract'), missing='', validator=Length(max=500)) relation_type = enum_property(PropositionRelationType, missing=None) related_proposition_id = string_property(missing=None)
class FlightFormSchema(MappingSchema): name = SchemaNode(String(), description='The name of this thing') title = SchemaNode(String(), widget=widget.TextInputWidget(size=40), validator=Length(max=20), description='A very short title') password = SchemaNode(String(), widget=widget.CheckedPasswordWidget(), validator=Length(min=5)) is_cool = SchemaNode(Boolean(), default=True )
class PropositionSchema(Schema): area_id = int_property(title=_('subject_area'), missing=None) title = string_property(title=_('title'), validator=Length(min=5, max=512)) external_discussion_url = string_property( title=_('external_discussion_url'), validator=colander.url) abstract = string_property(title=_('abstract'), validator=Length(min=5, max=2048)) content = string_property(title=_('content'), validator=Length(min=10, max=65536)) motivation = string_property(title=_('motivation'), missing='') tags = set_property(title=_('tags'), missing=tuple()) relation_type = string_property(validator=OneOf(['replaces', 'modifies']), missing=None) related_proposition_id = int_property(missing=None)
class MySchema(MappingSchema): name = SchemaNode(String(), description='The name of this thing') title = SchemaNode(String(), widget=widget.TextInputWidget(size=40), validator=Length(max=20), description='A very short title') password = SchemaNode(String(), widget=widget.CheckedPasswordWidget(), validator=Length(min=5)) is_cool = SchemaNode(Boolean(), default=True) dates = DatesSchema() color = SchemaNode(String(), widget=widget.RadioChoiceWidget(values=colors), validator=OneOf(('red', 'blue')))
class Address(MappingSchema): """ **Source:** `Primair onderwijs - Adressen <http://data.duo.nl/organisatie/open_onderwijsdata/databestanden/po/adressen/default.asp>`_ **Source:** `Voortgezet onderwijs - Adressen <http://data.duo.nl/organisatie/open_onderwijsdata/databestanden/vo/adressen/default.asp>`_ **Source:** `BAG42 Geocoding service <http://calendar42.com/bag42/>`_ """ street = SchemaNode( String(), validator=Length(min=4, max=300), title="Street name and number of the address of this branch.") city = city(title="Name of the city or village this branch is located.") zip_code = SchemaNode( String(), validator=Length(min=6, max=6), title= "Zip code of the address of this branch. A Dutch zip code consists of four digits, a space and two letters (*1234 AB*) [#zipcodes]_. For normalisation purposes, the whitespace is removed." ) geo_location = Coordinates( title="Latitude/longitude coordinates of this address.") geo_viewport = Viewport( title="Latitude/longitude coordinates of the viewport for this address" ) formatted_address = SchemaNode( String(), validator=Length(min=3, max=300), title= "Normalised address as returned by the BAG42 geocoding API [#bag42geo]_." ) @colander.instantiate() class address_components(SequenceSchema): @colander.instantiate() class address_component(MappingSchema): """**Source:** `BAG42 Geocoding service <http://calendar42.com/bag42/>`_""" long_name = SchemaNode( String(), validator=Length(min=4, max=300), title="Full name of this component. (*i.e. 'Nederland'*)") short_name = SchemaNode( String(), validator=Length(min=4, max=300), title= "Abbreviated form (if applicable) of the long_name. (*i.e. 'NL'*)" ) @colander.instantiate() class types(SequenceSchema): address_type = SchemaNode(String(), validator=Length(min=4, max=100))
class AverageItemSchema(SchemaNode): """A connection speed averages.""" schema_type = Mapping connection = SchemaNode(String(), validator=Length(1, 5), description='Connection type.') download = SchemaNode(String(), missing=None, validator=Length(1, 256), description='Download reading.') upload = SchemaNode(String(), missing=None, validator=Length(1, 256), description='Upload reading.')
class VotingPhaseSchema(Schema): name = string_property(title=_('name'), validator=Length(min=2, max=23), missing='') title = string_property(title=_('title'), validator=Length(min=5, max=140), missing='') target = date_property(title=_('target'), missing=None) status = enum_property(VotingStatus, title=_('voting_status')) department_id = int_property(title=_('department')) phase_type_id = int_property(title=_('voting_phase_type')) secret = bool_property(title=_('secret_voting_possible')) description = string_property(title=_('description'), validator=Length(min=10, max=65536), missing='')
class PolicySchema(Schema): name = string_property(title=_('name'), validator=Length(max=64)) description = string_property(title=_('description'), validator=Length(max=4000), missing='') majority = enum_property(Majority, title=_('majority')) proposition_expiration = int_property(title=_('proposition_expiration')) qualification_minimum = int_property(title=_('qualification_minimum')) qualification_quorum = decimal_property(title=_('qualification_quorum')) range_max = int_property(title=_('range_max')) range_small_max = int_property(title=_('range_small_max')) range_small_options = int_property(title=_('range_small_options')) secret_minimum = int_property(title=_('secret_minimum')) secret_quorum = decimal_property(title=_('secret_quorum')) submitter_minimum = int_property(title=_('submitter_minimum')) voting_duration = int_property(title=_('voting_duration')) voting_system = enum_property(VotingSystem, title=_('voting_system'))
class FormInserirP(CSRFSchema): """ Formulário para inserção de novo ponto/atividade no mapa """ atividade = SchemaNode( String(), title='Título', description='Nome do local') endereco = SchemaNode( String(), missing=unicode(''), description='Endereço do local', title='Endereço', validator=Length(max=100), widget=widget.TextAreaWidget(rows=1, cols=60) ) tipo = SchemaNode( String(), missing=unicode(''), widget=widget.SelectWidget(values=tipoLocal), title = "Gênero", ) """ foto = SchemaNode( deform.FileData(), widget=widget.FileUploadWidget(tmpstore), missing=unicode(''), description='Carregar foto' ) """ foto = SchemaNode( String(), missing=unicode(''), description='Carregar foto' ) video = SchemaNode( String(), missing=unicode(''), description='Carregar url de vídeo' ) descricao = SchemaNode( String(), missing=unicode(''), description='Comente sobre o orçamento', title='Descrição', validator=Length(max=100), widget=widget.TextAreaWidget(rows=10, cols=60) )
class Attribute(MappingSchema): label = SchemaNode(String(), missing=drop) description = SchemaNode(String(), missing='') column = SchemaNode(String(), validator=Length(min=1)) type = SchemaNode(String(), missing='string', validator=OneOf(TYPES.keys()))
class PermissionSchema(BaseModelSchema): """ Schema definition for permission model. """ name = SchemaNode(String(), validator=Length(min=3, max=50)) description = SchemaNode(String(), missing=drop)
class TitleSchema(MappingSchema): """Title sheet data structure. `title`: a human readable title """ title = SingleLine(validator=Length(min=3, max=200))
class CostPerYear(MappingSchema): amount_euro = SchemaNode(Int(), validator=Range(min=0, max=1000)) explanation = SchemaNode(String()) link = SchemaNode(String()) other_costs = SchemaNode(Boolean()) # Year can be a bunch of things ("Leerjaar 1", "alle jaren", ...) year = SchemaNode(String(), validator=Length(min=3, max=75))
class PropositionNewSchema(PropositionSchema): area_id = int_property(title=_('subject_area')) proposition_type_id = int_property(title=_('proposition_type')) editing_remarks = string_property( title=_('editing_remarks'), description=_('editing_remarks_description'), missing='', validator=Length(max=2000))
class address_component(MappingSchema): """**Source:** `BAG42 Geocoding service <http://calendar42.com/bag42/>`_""" long_name = SchemaNode( String(), validator=Length(min=4, max=300), title="Full name of this component. (*i.e. 'Nederland'*)") short_name = SchemaNode( String(), validator=Length(min=4, max=300), title= "Abbreviated form (if applicable) of the long_name. (*i.e. 'NL'*)" ) @colander.instantiate() class types(SequenceSchema): address_type = SchemaNode(String(), validator=Length(min=4, max=100))
def definition(cls, **kwargs): schema = super(EnumField, cls).definition() schema.add( SchemaNode(Sequence(), SchemaNode(String()), name='choices', validator=Length(min=1))) return schema
class Indicator(MappingSchema): grade = SchemaNode( Float(), validator=Range(min=0.0, max=10.0), title="The average grade student/parents awarded this indicator.") indicator = SchemaNode(String(), validator=Length(min=10, max=200), title="The indicator.")