Exemple #1
0
class EditForm(formencode.Schema):
    role = formencode.All(fv.UnicodeString(not_empty=False), fv.OneOf(ROLES))
    password = formencode.All(fv.UnicodeString(not_empty=False))
    first_name = formencode.All(fv.UnicodeString(not_empty=False),
                                fv.MaxLength(64))
    last_name = formencode.All(fv.UnicodeString(not_empty=False),
                               fv.MaxLength(64))
    default_timezone = fv.Int(not_empty=False)
    is_active = fv.Bool(not_empty=False)
Exemple #2
0
class UserRegistrationSchema(formencode.schema.Schema):
    login = Pipe(validators=[
        _v.Regex(_LOGIN_NAME_RE, strip=True),
        _v.MaxLength(inspect(User).c.login.type.length),
        _v.NotEmpty(messages={'empty': 'Please enter an login'}),
    ])
    name = Pipe(validators=[
        _v.MaxLength(inspect(User).c.name.type.length),
        _v.NotEmpty(messages={'empty': 'Please enter your real name'}),
    ])
Exemple #3
0
class ConferenceForm(formencode.Schema):
    allow_extra_fields = True
    extension = formencode.All(UniqueExtension(), validators.NotEmpty(),\
        validators.MinLength(3),\
        validators.String(not_empty=True),\
        validators.MaxLength(4))
    pin = formencode.All(validators.NotEmpty(),\
        validators.MinLength(3),\
        validators.String(not_empty=True),\
        validators.MaxLength(4))
Exemple #4
0
class VirtualMailboxForm(formencode.Schema):
    allow_extra_fields = True
    vmbox_number = formencode.All(UniqueExtension(), validators.NotEmpty(),\
        validators.MinLength(3),\
        validators.String(not_empty=True),\
        validators.MaxLength(4))
    vm_password = validators.Number(not_empty=True)
Exemple #5
0
class CrmCampaignForm(formencode.Schema):
    allow_extra_fields = True
    ignore_key_missing = True
    campaign_name = formencode.All(UniqueCampaign(), validators.MinLength(3),\
        validators.String(not_empty=True),\
        validators.MaxLength(32))
    campaign_extensions = validators.String(not_empty=True)
Exemple #6
0
class DIDForm(formencode.Schema):
    allow_extra_fields = True
    ignore_key_missing = True
    did = formencode.All(UniqueDID(), validators.MinLength(6),\
        validators.String(not_empty=True),\
        validators.MaxLength(15))
    customer_name = validators.String(not_empty=True)
Exemple #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=formencode.All(
             fev.String(not_empty=True), fev.MinLength(3),
             fev.MaxLength(15),
             fev.Regex(
                 r'^[A-z][-A-z0-9]{2,}$',
                 messages={
                     'invalid':
                     'Please use only letters, numbers, and dashes 3-15 characters long.'
                 }), NeighborhoodProjectTakenValidator()))
     tools = ew.CheckboxSet(
         name='tools',
         options=[
             ## Required for Neighborhood functional tests to pass
             ew.Option(label='Wiki', html_value='wiki', selected=True)
         ])
Exemple #8
0
class CIDForm(formencode.Schema):
    allow_extra_fields = True
    cid_number = formencode.All(validators.NotEmpty(),\
        validators.MinLength(10),\
        validators.String(not_empty=True),\
        validators.MaxLength(10))
    pbx_route_id = validators.Number(not_empty=True)
Exemple #9
0
class ProfileForm(formencode.Schema):
    allow_extra_fields = True
    name = formencode.All(UniqueProfile(), validators.MinLength(3),\
        validators.String(not_empty=True),\
        validators.MaxLength(64))
    odbc_credentials = validators.String(not_empty=True)
    dbname = validators.String(not_empty=True)
    presence_hosts = validators.String(not_empty=True)
    caller_id_type = validators.String(not_empty=True)
    auto_jitterbuffer_msec = validators.Int(not_empty=True)
    ext_rtp_ip = validators.String(not_empty=True)
    ext_sip_ip = validators.String(not_empty=True)
    sip_ip = validators.String(not_empty=True)
    sip_ip = validators.String(not_empty=True)
    sip_port = validators.Number(not_empty=True)
    nonce_ttl = validators.Number(not_empty=True)
    rtp_timer_name = validators.String(not_empty=True)
    codec_prefs = validators.String(not_empty=True)
    inbound_codec_negotiation = validators.String(not_empty=True)
    rtp_timeout_sec = validators.Number(not_empty=True)
    rtp_hold_timeout_sec = validators.Number(not_empty=True)
    rfc2833_pt = validators.Number(not_empty=True)
    dtmf_duration = validators.Number(not_empty=True)
    dtmf_type = validators.String(not_empty=True)
    session_timeout = validators.Number(not_empty=True)
    multiple_registrations = validators.String(not_empty=True)
    vm_from_email = validators.String(not_empty=True)
Exemple #10
0
class VirtualExtensionForm(formencode.Schema):
    allow_extra_fields = True
    vextension_number = formencode.All(UniqueExtension(),\
        validators.NotEmpty(),\
        validators.MinLength(3),\
        validators.String(not_empty=True),\
        validators.MaxLength(4))
    vextension_did = validators.Number(not_empty=True)
Exemple #11
0
class RegisterForm(formencode.Schema):

    name = fv.UnicodeString(not_empty=True, max=128)
    email = formencode.All(fv.Email(not_empty=True), fv.MaxLength(256),
                           UniqueEmail())
    password = fv.UnicodeString(not_empty=True, min=5)
    confirm_password = fv.UnicodeString(not_empty=True, min=5)
    default_timezone = fv.Int(not_empty=True)
    username = fv.UnicodeString(not_empty=False, min=4, max=64)
    first_name = fv.UnicodeString(not_empty=False, max=64)
    last_name = fv.UnicodeString(not_empty=False, max=64)

    chained_validators = [fv.FieldsMatch('password', 'confirm_password')]
Exemple #12
0
class MappingSystemDescriptionSchema(Schema):
    if_key_missing = None

    Name = ciocvalidators.UnicodeString(max=50)
    Label = ciocvalidators.UnicodeString(max=200)
    String = Pipe(ciocvalidators.URLWithProto(max=255),
                  validators.MaxLength(255))

    chained_validators = [
        ciocvalidators.RequireIfAny("Name", present=("Label", "String")),
        ciocvalidators.RequireIfAny("Label", present=("Name", "String")),
        ciocvalidators.RequireIfAny("String", present=("Name", "Label")),
    ]
Exemple #13
0
    def set_length(self, len):
        # if size is none, set it to None and return
        if len is None:
            return

        # make sure the size is an integer
        if not isinstance(1, type(len)):
            raise TypeError('maxlength should have been int but was %s' % type(len))

        self.set_attr('maxlength', len)

        # set a maxlength validator on this
        self.add_processor(fev.MaxLength(len))
Exemple #14
0
 def __init__(self, request):
     formfields = [
         FormField('description',
                   label='Beschreibung',
                   size=20,
                   required=False,
                   validator=validators.MaxLength(20))
     ]
     ObjectForm.__init__(self,
                         None,
                         formfields,
                         request,
                         send='Generiere API-Key')
    def create_fe_validators(self):
        # grab some values from the kwargs that apply to this validator
        validate_length = bool(self.kwargs.get('length', True))
        validate_nullable = bool(self.kwargs.get('nullable', True))
        validate_type = bool(self.kwargs.get('type', True))
        excludes = self.kwargs.get('exclude', [])

        for colname in self.entitycls._sav_column_names():
            # get the SA column instance
            col = self.entitycls.__mapper__.get_property(colname).columns[0]

            # ignore primary keys
            if colname in excludes or col.primary_key:
                continue

            # validate lengths on String and Unicode types, but not Text b/c it shouldn't have a
            # length
            if validate_length and isinstance(col.type, sa.types.String) \
                    and not isinstance(col.type, sa.types.Text):
                fmeta = FEVMeta(fev.MaxLength(col.type.length), colname)
                self.fev_metas.append(fmeta)

            if validate_type and isinstance(col.type, sa.types.Numeric):
                fmeta = FEVMeta(
                    NumericValidator(col.type.precision, col.type.scale),
                    colname)
                self.fev_metas.append(fmeta)

            # handle fields that are not nullable
            if validate_nullable and not col.nullable:
                if not col.default and not col.server_default:
                    validator = formencode.FancyValidator(not_empty=True)
                    event = 'before_flush'
                    if col.foreign_keys:
                        event = 'before_exec'
                    fmeta = FEVMeta(validator, colname, event)
                    self.fev_metas.append(fmeta)

            # data-type validation
            if validate_type:
                for sa_type, fe_validator in six.iteritems(
                        SA_FORMENCODE_MAPPING):
                    if isinstance(col.type, sa_type):
                        self.create_fev_meta(fe_validator,
                                             colname,
                                             auto_not_empty=False)
                        break
Exemple #16
0
    # NOTE some field validators added dynamically below


all_fields = tuple(
    TemplateBaseSchema.fields.keys()) + colour_fields + link_fields

for field in colour_fields:
    TemplateBaseSchema.add_field(field, ciocvalidators.HexColourValidator())

for field in link_fields:
    TemplateBaseSchema.add_field(
        field,
        Pipe(
            ciocvalidators.URLWithProto(add_http=True, require_tld=False),
            validators.MaxLength(150),
        ),
    )


class TemplateDescriptionSchema(Schema):
    if_key_missing = None

    Name = ciocvalidators.UnicodeString(max=150)
    Logo = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    LogoAltText = ciocvalidators.UnicodeString(max=255)
    LogoLink = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
Exemple #17
0
class CountryForm(Schema):
    filter_extra_fields = True
    allow_extra_fields = True
    code = validators.MaxLength(2, not_empty=True)
    name = validators.String(not_empty=True)
Exemple #18
0
class LoginForm(formencode.Schema):
    username = formencode.All(fv.UnicodeString(not_empty=True),
                              fv.MaxLength(64))
    password = formencode.All(fv.UnicodeString(not_empty=True),
                              fv.MaxLength(32))
Exemple #19
0
 class Form(formencode.Schema):
     email = formencode.All(fv.Email(not_empty=True), fv.MaxLength(256))
     role = fv.OneOf(APP_ROLES, not_empty=True)
class ClientPasswordChangeForm(Schema):
    oldPassword = formencode.All(validators.UnicodeString(not_empty=True), validators.MaxLength(253))
#    newPassword = formencode.All(ClientPassword(not_empty=True), validators.MaxLength(253))
    newPassword = formencode.All(validators.UnicodeString(not_empty=True), validators.MaxLength(253))
    newPasswdConfirm = formencode.All(validators.UnicodeString(not_empty=True), validators.MaxLength(253))
    chained_validators = [validators.FieldsMatch('newPassword', 'newPasswdConfirm')]
class LoginForm(Schema):
#    captcha = validators.UnicodeString(not_empty=True)
#    user = formencode.All(validators.PlainText(not_empty=True), validators.MaxLength(30))
    user = formencode.All(validators.UnicodeString(not_empty=True), validators.MaxLength(30))
    passwd = formencode.All(validators.UnicodeString(not_empty=True), validators.MaxLength(253))
Exemple #22
0
class GroupEditForm(formencode.Schema):
    allow_extra_fields = True
    group_name = formencode.All(validators.MinLength(3),\
        validators.String(not_empty=True),\
        validators.MaxLength(32))
    group_extensions = validators.String(not_empty=True)
Exemple #23
0
class FaxForm(formencode.Schema):
    allow_extra_fields = True
    fax_name = formencode.All(UniqueFax(), validators.MinLength(3),\
        validators.String(not_empty=True),\
        validators.MaxLength(32))
Exemple #24
0
class PbxBlacklistedForm(formencode.Schema):
    allow_extra_fields = True
    cid_number = formencode.All(validators.NotEmpty(),\
        validators.MinLength(10),\
        validators.String(not_empty=True),\
        validators.MaxLength(10))
Exemple #25
0
class TTSForm(formencode.Schema):
    allow_extra_fields = True
    name = formencode.All(UniqueTTS(), validators.MaxLength(64))
    tts_text = validators.String(not_empty=True)
Exemple #26
0
class IVRForm(formencode.Schema):
    allow_extra_fields = True
    ivr_name = formencode.All(UniqueIVR(), validators.MaxLength(64))
Exemple #27
0
class NewsCreateSchema(BaseSchema):
    """ Schema for single news form """
    title = validators.MaxLength(60, not_empty=True)
    text = validators.MinLength(10, not_empty=True)
    image_url = validators.URL(add_http=False, check_exists=True)
Exemple #28
0
 class Pref(formencode.Schema):
     key = fv.MaxLength(64, not_empty=True)
     value = fv.MaxLength(64, not_empty=False)
Exemple #29
0
class TemplateDescriptionSchema(Schema):
    if_key_missing = None

    Name = ciocvalidators.UnicodeString(max=150)
    Logo = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    LogoAltText = ciocvalidators.UnicodeString(max=255)
    LogoLink = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    LogoMobile = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    Banner = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    CopyrightNotice = ciocvalidators.UnicodeString(max=255)
    headerGroup1 = ciocvalidators.UnicodeString(max=100)
    headerGroup2 = ciocvalidators.UnicodeString(max=100)
    headerGroup3 = ciocvalidators.UnicodeString(max=100)
    footerGroup1 = ciocvalidators.UnicodeString(max=100)
    footerGroup2 = ciocvalidators.UnicodeString(max=100)
    footerGroup3 = ciocvalidators.UnicodeString(max=100)
    cicsearchGroup1 = ciocvalidators.UnicodeString(max=100)
    cicsearchGroup2 = ciocvalidators.UnicodeString(max=100)
    cicsearchGroup3 = ciocvalidators.UnicodeString(max=100)
    volsearchGroup1 = ciocvalidators.UnicodeString(max=100)
    volsearchGroup2 = ciocvalidators.UnicodeString(max=100)
    volsearchGroup3 = ciocvalidators.UnicodeString(max=100)
    Agency = ciocvalidators.UnicodeString(max=255)
    Address = ciocvalidators.UnicodeString(max=255)
    Phone = ciocvalidators.UnicodeString(max=255)
    Email = ciocvalidators.UnicodeString(max=150)
    Web = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    Facebook = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    Twitter = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    Instagram = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    LinkedIn = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    YouTube = Pipe(
        ciocvalidators.URLWithProto(add_http=True, require_tld=False),
        validators.MaxLength(255),
    )
    TermsOfUseLink = ciocvalidators.UnicodeString(max=255)
    TermsOfUseLabel = ciocvalidators.UnicodeString(max=255)
    FooterNotice = ciocvalidators.UnicodeString(max=3000)
    FooterNotice2 = ciocvalidators.UnicodeString(max=2000)
    FooterNoticeContact = ciocvalidators.UnicodeString(max=2000)
    HeaderNotice = ciocvalidators.UnicodeString(max=2000)
    HeaderNoticeMobile = ciocvalidators.UnicodeString(max=1000)

    chained_validators = [
        ciocvalidators.RequireIfAny(
            "Name",
            present=(
                "LogoLink",
                "Logo",
                "CopyrightNotice",
                "LogoMobile",
                "LogoAltText",
                "Banner",
                "Agency",
                "Address",
                "Phone",
                "Email",
                "Web",
                "Facebook",
                "Twitter",
                "Instagram",
                "LinkedIn",
                "YouTube",
            ),
        )
    ]
Exemple #30
0
class CreateForm(formencode.Schema):
    subdomain = formencode.All(SUBDOMAIN_VALIDATOR, UniqueSubdomain())
    company_name = fv.UnicodeString(not_empty=True, min=4, max=64)
    url = formencode.All(fv.MaxLength(512, not_empty=False), fv.URL())