Пример #1
0
class AsteriskSave(validators.Schema):
    targetname = KnownUser
    asterisk_enabled = validators.OneOf(['0', '1'], not_empty=True)
    asterisk_pass = validators.All(
        ValidAsteriskPass,
        validators.String(min=6, not_empty=True),
    )
Пример #2
0
class UserEditSchema(validators.Schema):
    """
    separate validation schema from the fields definition
    make it possible to define a more complex schema
    that involves field dependency or logical operators
    """
    user_name = validators.String(not_empty=True, max=16)
    status = validators.OneOf(['ENABLED', 'LOCKED', 'DISABLED'])
    password = validators.UnicodeString(max=50)
    password_confirm = validators.UnicodeString(max=50)
    chained_validators = [
        validators.FieldsMatch('password', 'password_confirm')
    ]
Пример #3
0
class InputFieldsSchema(validators.Schema):

    # Regex validator ensures only certain characters are input, essentially alphanumeric with new lines and spaces
    peptide = validators.All(
        accesionOrSeq(), validators.String(min=3),
        validators.Regex(
            r'^[^\x00-\x09\x0B-\x0C\x0E-\x1F\x21-\x2F\x3A-\x3C\x3F-\x40\x5B-\x5E\x60\x7B\x7D-\x7F]*$'
        ))
    enzyme = validators.OneOf([
        "Chymotrypsin", "Chymotrypsin Low Specificity", "Trypsin",
        "Pepsin (ph = 1.3)", "Pepsin (ph >= 2.0)"
    ])
    misses = validators.Int(if_empty=0, min=0, max=50)
    minlen = validators.Int(if_empty=0, min=0)
    maxlen = validators.Int(if_empty=1000000000, min=0)
    minweight = validators.Int(if_empty=500, min=0)
    maxweight = validators.Int(if_empty=1000000000, min=0)
Пример #4
0
class YubikeySave(validators.Schema):
    targetname = KnownUser
    yubikey_enabled = validators.OneOf(['0', '1'], not_empty=True)
    yubikey_prefix = validators.String(min=12, max=12, not_empty=True)
Пример #5
0
class NewUpdateForm(Form):
    template = "bodhi.templates.new"
    submit_text = "Save Update"
    update_types = config.get('update_types').split()
    request_types = ['Testing', 'Stable', 'None', None]
    fields = [
            AutoCompleteField('builds', label='Package',
                              search_controller=url('/new/search'),
                              search_param='name', result_name='pkgs',
                              template='bodhi.templates.packagefield',
                              validator=AutoCompleteValidator()),
            CheckBox('inheritance', label='Follow Build inheritance',
                     validator=validators.StringBool(),
                     default=False, attrs={'title' : 'Build Inheritance - '
                                                     'TODO'}),
            SingleSelectField('type_', label='Type', options=update_types,
                              validator=validators.OneOf(update_types)),
            SingleSelectField('request', options=request_types,
                              validator=validators.OneOf(request_types +
                                  [r.lower() for r in request_types if r]),
                              default='testing'),
            TextField('bugs', validator=BugValidator(),
                      attrs={'title' : 'Bug Numbers - A space or comma '
                                       'delimited list of bug numbers or '
                                       'aliases.  Example: #1234, 789 '
                                       'CVE-2008-0001'}),
            TextArea('notes', validator=validators.UnicodeString(),
                     rows=13, cols=65,
                     attrs={'title' : 'Advisory Notes - <p>Some details '
                                      'about this update that will appear in '
                                      'the notice.</p>'
                                      '<p><strong>Example:</strong><br />'
                                      'This is an update that fixes problems with '
                                      '**<strong>connecting to a share</strong>**.</p>'
                                      '<p>The following things *<em>break</em>*:</p>'
                                      '<p>* Browsing with `<code>gnome-app-install</code>`<br />'
                                      '* Emailing</p>'}),
            CheckBox(name='close_bugs', help_text='Automatically close bugs',
                     validator=validators.StringBool(),
                     default=True, attrs={'title' : 'Close Bugs - '
                                                    'Automatically close bugs '
                                                    'when this update is '
                                                    'pushed as stable'}),
            HiddenField('edited', default=None),
            CheckBox(name='suggest_reboot', label='Suggest Reboot',
                     validator=validators.StringBool(),
                     default=False, attrs={'title': 'Suggest Reboot - '
                                                    'Recommend that the user '
                                                    'restarts their machine '
                                                    'after installing this '
                                                    'update'}),
            CheckBox(name='autokarma', label='Enable karma automatism',
                     default=True, validator=validators.StringBool(),
                     attrs={'onchange':
                         'if ($("#form_autokarma").attr("checked")) {'
                            '$("#form_stable_karma").attr("disabled", false);'
                            'if ($("#form_stable_karma").attr("value") == 0) $("#form_stable_karma").attr("value", 3);'
                            '$("#form_unstable_karma").attr("disabled", false);'
                            'if ($("#form_unstable_karma").attr("value") == 0) $("#form_unstable_karma").attr("value", -3);'
                         ' } else { '
                            '$("#form_stable_karma").attr("disabled", true);'
                            '$("#form_unstable_karma").attr("disabled", true);'
                         '}',
                    'title': 'Karma Automatism - Enable update request '
                             'automation based on user feedback',
                            }),
            TextField('stable_karma', label='Threshold for pushing to stable',
                      validator=validators.Int(), default='3',
                      attrs={'title' : 'Stable Karma - The threshold for '
                             'automatically pushing this update to stable',
                             'size' : '1'}),
            TextField('unstable_karma', label='Threshold for unpushing',
                      validator=validators.Int(), default='-3',
                      attrs={'title' : 'Unstable Karma - The threshold for '
                             'automatically unpushing an unstable update',
                             'size' : '1'})
    ]