Example #1
0
class AddEntrySchema(MappingSchema):
    project_id = SchemaNode(Integer())
    ticket_id = SchemaNode(TicketObject())
    time = SchemaNode(TimeObject(), validator=Range(0.0, 24.00))
    description = SchemaNode(String())
    timer = SchemaNode(Boolean())
    add_to_harvest = SchemaNode(Boolean())
Example #2
0
class AccountSettings(MappingSchema):
    fullname = SchemaNode(String())
    email = SchemaNode(String(), validator=Email())
    public_email = SchemaNode(Boolean(), missing=False)
    twitter = SchemaNode(String(), missing=None, validator=Length(max=140))
    public_twitter = SchemaNode(Boolean(), missing=False)
    password1 = SchemaNode(String(), missing=None, default=None)
    password2 = SchemaNode(String(), missing=None, default=None)
Example #3
0
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())
Example #4
0
class WindSchema(base_schema.ObjTypeSchema):
    '''
    validate data after deserialize, before it is given back to pyGnome's
    from_dict to set _state of object
    '''
    name = SchemaNode(String(), test_equal=False)
    description = SchemaNode(String())
    filename = FilenameSchema(isdatafile=True, update=False,
                              test_equal=False)  #Thanks to CyTimeseries
    updated_at = SchemaNode(LocalDateTime())
    latitude = SchemaNode(Float())
    longitude = SchemaNode(Float())
    source_id = SchemaNode(String())
    source_type = SchemaNode(String(),
                             validator=OneOf(wind_datasources._attr),
                             default='undefined',
                             missing='undefined')
    units = SchemaNode(String(), default='m/s')
    speed_uncertainty_scale = SchemaNode(Float())
    timeseries = WindTimeSeriesSchema(
        test_equal=False
    )  #Because comparing datetimevalue2d arrays does not play nice
    extrapolation_is_allowed = SchemaNode(Boolean())
    data_start = SchemaNode(LocalDateTime(),
                            read_only=True,
                            validator=convertible_to_seconds)
    data_stop = SchemaNode(LocalDateTime(),
                           read_only=True,
                           validator=convertible_to_seconds)
Example #5
0
class BinaryOutputSchema(BaseOutputterSchema):
    filename = SchemaNode(
        String(), missing=drop, save=True, update=True
    )
    zip_output = SchemaNode(
        Boolean(), missing=drop, save=True, update=True
    )
Example #6
0
class ShapeSchema(BaseOutputterSchema):
    filename = FilenameSchema(
        missing=drop, save=True, update=True, test_equal=False
    )
    zip_output = SchemaNode(
        Boolean(), missing=drop, save=True, update=True
    )
Example #7
0
class WebhookSchema(MappingSchema):
    url = SchemaNode(String(), location='body', validator=url)
    event_type = SchemaNode(String(),
                            location='body',
                            validator=OneOf(
                                [value for value, label in Webhook.TYPES]))
    active = SchemaNode(Boolean(), location='body')
Example #8
0
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))
Example #9
0
def ballot_voting_form(ballot_voting, request):

    yes_no_choices = [(True, _('Yes')), (False, _('No')), (None, _('Abstention'))]
    max_points = 9 if len(ballot_voting.options) > 3 else 3
    point_choices = [(i, str(i)) for i in range(max_points+1)]

    schema = Schema()

    for option in ballot_voting.options:

        option_schema = SchemaNode(Mapping(), name=str(option.uuid), title=option.title)

        option_schema.add(SchemaNode(
            Boolean(),
            validator=OneOf([x[0] for x in yes_no_choices]),
            widget=RadioChoiceWidget(values=yes_no_choices, inline=True),
            name='yes_no',
            title=f'Stimmst du dem Antrag zu?'))

        option_schema.add(SchemaNode(
            Int(),
            validator=OneOf([x[0] for x in point_choices]),
            widget=RadioChoiceWidget(values=point_choices, inline=True, null_value='0'),
            name='points',
            title='Welche Punktzahl gibst du dem Antrag?',
            missing=0))

        schema.add(option_schema)

    form = Form(schema, request, buttons=[Button(title=_('check'))])
    return form
Example #10
0
class Dimension(MappingSchema):
    label = SchemaNode(String(), missing=drop)
    description = SchemaNode(String(), missing='')
    label_attribute = SchemaNode(String(), missing=None)
    key_attribute = SchemaNode(String(), missing=None)
    facet = SchemaNode(Boolean(), missing=False)
    # cardinality = SchemaNode(Int(), missing=None, default=None)
    attributes = Attributes(validator=Function(require_one_child))
Example #11
0
class FilterPreferencesSchema(MappingSchema):
    activities = SchemaNode(Sequence(),
                            SchemaNode(String(), validator=OneOf(activities)),
                            missing=required)
    langs = SchemaNode(Sequence(),
                       SchemaNode(String(), validator=OneOf(default_langs)),
                       missing=required)
    areas = SchemaNode(Sequence(), SchemaAssociationDoc(), missing=required)
    followed_only = SchemaNode(Boolean(), missing=required)
Example #12
0
class ValidCellSchema(ValidCellBaseSchema):
    """
    A Schema which validates the fields present in
    all Cells.
    """
    created = SchemaNode(DateTimeFromString(), missing=None)
    modified = SchemaNode(DateTimeFromString(), missing=None)
    changeable = SchemaNode(Boolean(), missing=True)
    total_measures = SchemaNode(Integer(), missing=0)
    range = SchemaNode(Integer(), missing=0)
Example #13
0
class SubstanceSchema(ObjTypeSchema):
    initializers = SequenceSchema(
        GeneralGnomeObjectSchema(
            acceptable_schemas=[InitWindagesSchema,
                                DistributionBaseSchema
                                ]
        ),
        save=True, update=True, save_reference=True
    )
    is_weatherable = SchemaNode(Boolean(), read_only=True)
Example #14
0
class FormSeguirAtv(CSRFSchema):
    """ 
    Formulário para seguir atividade orçamentária/usuário
    """	
    seguir = SchemaNode(
        Boolean(),	
        label='Receber atualizações desta atividade',
        widget=widget.CheckboxWidget(),
        title='Seguir',
        missing=unicode(''),		
    )		
Example #15
0
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
                         )
Example #16
0
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()
Example #17
0
 class MySchema(MappingSchema):
     name = SchemaNode(String())
     title = SchemaNode(String())
     cool = SchemaNode(Boolean(), default=True, missing=True)
     series = SeriesSchema()
     nickname = SchemaNode(
         String(),
         widget=deform.widget.TextInputWidget(
             attributes={
                 "maxlength": 10,
                 "placeholder": "Nickname",
                 "disabled": "disabled",
             }),
     )
Example #18
0
class TideSchema(base_schema.ObjTypeSchema):
    'Tide object schema'
    filename = FilenameSchema(
        save=True, update=False, isdatafile=True, test_equal=False
    )

    scale_factor = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    extrapolation_is_allowed = SchemaNode(Boolean(), missing=drop, read_only=True)
    data_start = SchemaNode(LocalDateTime(), read_only=True,
                            validator=convertible_to_seconds)
    data_stop = SchemaNode(LocalDateTime(), read_only=True,
                           validator=convertible_to_seconds)
Example #19
0
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')))
Example #20
0
class VariableSchemaBase(base_schema.ObjTypeSchema):
    #filename
    #data?
    units = SchemaNode(String())
    time = TimeSchema(save_reference=True)
    grid = GridSchema(save_reference=True)
    data_file = FilenameSchema(isdatafile=True, test_equal=False, update=False)
    grid_file = FilenameSchema(isdatafile=True, test_equal=False, update=False)
    extrapolation_is_allowed = SchemaNode(Boolean())
    data_start = SchemaNode(LocalDateTime(),
                            read_only=True,
                            validator=convertible_to_seconds)
    data_stop = SchemaNode(LocalDateTime(),
                           read_only=True,
                           validator=convertible_to_seconds)
Example #21
0
class DatasetForm(Schema):
    label = SchemaNode(String(),
                       preparer=prepare_name,
                       validator=Length(min=2))
    name = SchemaNode(String(), preparer=prepare_name, validator=dataset_name)
    description = SchemaNode(String(), missing=drop)
    private = SchemaNode(Boolean(), missing=drop)
    currency = SchemaNode(String(),
                          missing=drop,
                          validator=OneOf(CURRENCIES.keys()))
    category = SchemaNode(String(),
                          missing=drop,
                          validator=OneOf(CATEGORIES.keys()))
    languages = DatasetLanguages(missing=drop)
    territories = DatasetTerritories(missing=drop)
Example #22
0
class ProjectSchema(BaseModelSchema):
    """
    Schema definition for Project model.

    """
    name = SchemaNode(String(), validator=Length(min=3))
    parent_id = SchemaNode(Integer(), missing=drop)
    client_id = SchemaNode(Integer(), missing=drop)
    user_id = SchemaNode(Integer())
    is_public = SchemaNode(Boolean(),
                           validator=RequirePermissions(
                               PERMISSION.get('project',
                                              'set_is_public',
                                              context=__name__)),
                           missing=drop)
Example #23
0
    def definition(cls, **kwargs):
        schema = SchemaNode(Mapping(unknown="preserve"))

        if kwargs.get('named', True):
            schema.add(
                SchemaNode(String(),
                           name='name',
                           validator=Regex(r'^[a-zA-Z][a-zA-Z0-9_\-]*$')))

        schema.add(SchemaNode(String(), name='label', missing=u''))
        schema.add(SchemaNode(String(), name='hint', missing=cls.hint))
        schema.add(SchemaNode(Boolean(), name='required',
                              missing=cls.required))
        schema.add(
            SchemaNode(String(), name='type', validator=OneOf(registry.names)))
        return schema
class Costs(MappingSchema):
    explanation = SchemaNode(
        String(),
        validator=Length(min=3, max=5000),
        title="Optional explanation provided by the school.")
    documents = Documents(
        title=
        "Array containing URLs (string) to documents the school published regarding the costs for parents."
    )
    signed_code_of_conduct = SchemaNode(
        Boolean(),
        title=
        "*True* if the school signed the code of conduct of the VO-raad [#voraad]_ regarding school costs [#coc]_."
    )
    per_year = CostsPerYear(
        title=
        "Many schools provide a detailed overview of the costs per year, which are described in this array."
    )
class CostPerYear(MappingSchema):
    amount_euro = SchemaNode(Int(),
                             validator=Range(min=0, max=1000),
                             title="Costs in € (euro) for this year.")
    explanation = SchemaNode(
        String(),
        title=
        "Optional explanation of the details of the costs (*for a labcoat, for travel, ...*)"
    )
    link = SchemaNode(String(),
                      title="Optional URL to a document detailing costs.")
    other_costs = SchemaNode(
        Boolean(),
        title=
        "Indication whether parents should expect additional costs, other than the costs mentioned here."
    )
    # Year can be a bunch of things ("Leerjaar 1", "alle jaren", ...)
    year = SchemaNode(
        String(),
        validator=Length(min=3, max=75),
        title="String representation of the years these costs apply to.")
Example #26
0
class RandomMover3DSchema(ProcessSchema):
    vertical_diffusion_coef_above_ml = SchemaNode(Float(),
                                                  missing=drop,
                                                  save=True,
                                                  update=True)
    vertical_diffusion_coef_below_ml = SchemaNode(Float(),
                                                  missing=drop,
                                                  save=True,
                                                  update=True)
    mixed_layer_depth = SchemaNode(Float(),
                                   missing=drop,
                                   save=True,
                                   update=True)
    horizontal_diffusion_coef_above_ml = SchemaNode(Float(),
                                                    missing=drop,
                                                    save=True,
                                                    update=True)
    horizontal_diffusion_coef_below_ml = SchemaNode(Float(),
                                                    missing=drop,
                                                    save=True,
                                                    update=True)
    surface_is_allowed = SchemaNode(Boolean())
Example #27
0
class FormCadastrar(CSRFSchema):
    """ 
    Formulário para cadastro de novo usuário
    falta acesso para termos e condições de uso
    """
    nome = SchemaNode(
        String(),
        validator=All(
            Length(max=32),
            #Function(verif_nome_unico, u"Nome já cadastrado"),
            Regex("^(\w)*$", "Usar apenas letras, números ou _"),
        ),
        description='Digite seu nome de usuário'
    )
    email = SchemaNode(
        String(),
        validator=deferred_verif_email_unico,
        description='Digite seu e-mail',
        widget=widget.CheckedInputWidget(
            subject='Email',
            confirm_subject='Confirmar e-mail',
            size=40)
	)
    senha = SchemaNode(
        String(),
        validator=Length(min=5, max=32),
        widget=widget.CheckedPasswordWidget(size=20),
        description='Digite sua senha (no mínimo 5 caracteres) e a confirme'
    )
    confirmar = SchemaNode(
        Boolean(),	
        #description='Aceitar termos e condições',
        label='Aceitar termos e condições',
        widget=widget.CheckboxWidget(),
        title='Confirmar',
        validator=Function(lambda x: x, u'É necessário aceitar as condições'),
    )			
Example #28
0
class PrettyQuerySchema(MappingSchema):
    pretty = SchemaNode(Boolean(),
                        missing=False,
                        location='querystring',
                        description='readable output formatting')
Example #29
0
 class MySchema(MappingSchema):
     name = SchemaNode(String())
     title = SchemaNode(String())
     cool = SchemaNode(Boolean(), default=True, missing=True)
     series = SeriesSchema()
Example #30
0
class Costs(MappingSchema):
    explanation = SchemaNode(String(), validator=Length(min=3, max=5000))
    documents = Documents()
    signed_code_of_conduct = SchemaNode(Boolean())
    per_year = CostsPerYear()