Exemplo n.º 1
0
class ChangePasswordSchema(Schema):
    """修改密码schema,提供公司所有变量的验证
    """
    allow_extra_fields = True
    filter_extra_fields = True
    oldpassword = formencode.All(validators.String(not_empty=True,min=8,max=30,
            messages=dict(empty=(u'旧密码不能为空' ),tooLong=(u'密码最长不能超过 %(max)i'),\
            tooShort=(u'密码最短不能少于 %(min)i'))),PasswordIsMatched())
    newpassword = validators.String(not_empty=True,min=8,max=30,messages=dict(empty=\
            (u'新密码不能为空' ),tooLong=(u'密码最长不能超过 %(max)i'),tooShort=(u'密码最短不能少于 %(min)i')))
Exemplo n.º 2
0
class ChangeRoleSchema(CSRFSchema):
    """The :class:`~wte.views.user_role.ChangeRoleSchema` handles the
    validation of a "change_role" action applied in :func:`~wte.views.user_role.update`.
    """
    action = formencode.All(formencode.validators.UnicodeString(not_empty=True),
                            formencode.validators.OneOf(['change_role']))
    """The action to apply"""
    role_id = formencode.ForEach(formencode.validators.Int(not_empty=True),
                                 convert_to_list=True,
                                 if_missing=formencode.api.NoDefault,
                                 not_empty=True)
    """The list of :class:`~wte.models.UserPartRole` to apply the action to"""
    role = formencode.All(formencode.validators.UnicodeString(not_empty=True),
                          formencode.validators.OneOf(['owner', 'tutor', 'student']))
    """The new role"""
    q = formencode.validators.UnicodeString(if_empty=None, if_missing=None)
    """Optional query parameter for the redirect"""
    start = formencode.validators.UnicodeString(if_empty=None, if_missing=None)
    """Optional start parameter for the redirect"""
Exemplo n.º 3
0
class UserForm(formencode.Schema):
    allow_extra_fields = True
    ignore_key_missing = True
    first_name = validators.String(not_empty=True)
    last_name = validators.String(not_empty=True)
    username = formencode.All(UniqueUsername())
    password = SecurePassword()
    address = validators.String(not_empty=False)
    address_2 = validators.String(not_empty=False)
    city = validators.String(not_empty=False)
    state = validators.String(not_empty=False)
    zip = validators.String(not_empty=False)
    tel = validators.String(not_empty=False)
    mobile = validators.String(not_empty=False)
Exemplo n.º 4
0
class ActionSchema(CSRFSchema):
    """The :class:`~wte.views.user_role.ActionSchema` handles the
    validation of a actions applied in :func:`~wte.views.user_role.action` and
    :func:`~wte.views.user_role.update`.
    """
    action = formencode.All(formencode.validators.UnicodeString(not_empty=True),
                            formencode.validators.OneOf(['block', 'remove', 'change_role']))
    """The action to apply"""
    role_id = formencode.ForEach(formencode.validators.Int(not_empty=True),
                                 convert_to_list=True,
                                 if_missing=formencode.api.NoDefault,
                                 not_empty=True)
    """The list of :class:`~wte.models.UserPartRole` to apply the action to"""
    allow_extra_fields = True
Exemplo n.º 5
0
class AddUserSchema(CSRFSchema):
    """The :class:`~wte.views.user_role.AddUserSchema` handles the
    validation of a adding a :class:`~wte.models.User` to a
    :class:`~wte.models.Part`..
    """
    user_id = formencode.ForEach(formencode.validators.Int(not_empty=True),
                                 convert_to_list=True)
    """The id of the :class:`~wte.models.User` to add"""
    role = formencode.All(formencode.validators.UnicodeString(not_empty=True),
                          formencode.validators.OneOf(['owner', 'tutor', 'student']))
    """The new role for the :class:`~wte.models.User`"""
    q = formencode.validators.UnicodeString(not_empty=False)
    """Save the query in case there are validation errors"""
    start = formencode.validators.Int(not_empty=False, if_missing=0)
    """Save the pagination in case there are validation errors"""
Exemplo n.º 6
0
class RegisterForm(formencode.Schema):
    """
    Validator for the registration form rendered by 
    ``AccountController.register()``and accepted by 
    ``AccountController.submit()``
    """
    allow_extra_fields = True
    filter_extra_fields = True
    fullname =v.UnicodeString()
    username = formencode.All(v.UnicodeString(not_empty=True), 
                              UsernameValidator())
    password =v.UnicodeString(not_empty=True)
    confirm_password =v.UnicodeString(not_empty=True)
    email =v.Email(not_empty=True)
    confirm_email =v.Email(not_empty=True)
    chained_validators = [v.FieldsMatch('email', 'confirm_email'),
                          v.FieldsMatch('password', 'confirm_password')]
Exemplo n.º 7
0
 class fields(ew_core.NameList):
     project_description = ew.HiddenField(label='Public Description')
     neighborhood = ew.HiddenField(label='Neighborhood')
     private_project = ew.Checkbox(label="", attrs={'class': 'unlabeled'})
     project_name = ew.InputField(label='Project Name',
                                  field_type='text',
                                  validator=formencode.All(
                                      fev.UnicodeString(not_empty=True,
                                                        max=40),
                                      V.MaxBytesValidator(max=40)))
     project_unixname = ew.InputField(
         label='Short Name', field_type='text',
         validator=None)  # will be set in __init__
     tools = ew.CheckboxSet(
         name='tools',
         options=[
             ## Required for Neighborhood functional tests to pass
             ew.Option(label='Wiki', html_value='wiki', selected=True)
         ])