示例#1
0
class SpaceUrlForm(Form):
    url = TextField(
        lazy_gettext('Space URL'),
        [validators.Length(min=6, max=200),
         validators.URL()],
        description=lazy_gettext("Drop here the URL of the Space."),
        default="http://graasp.epfl.ch/#item=space_1234")
示例#2
0
class RegistrationForm(Form):
    full_name = TextField(lazy_gettext('School name'),
                          [validators.Required(),
                           validators.Length(min=4)] +
                          forms.SCHOOL_FULL_NAME_VALIDATORS,
                          description=lazy_gettext('School name.'))
    short_name = TextField(
        lazy_gettext('Short name'),
        [validators.Required()] + forms.SCHOOL_SHORT_NAME_VALIDATORS,
        description=lazy_gettext(
            'Short name (lower case, all letters, dots and numbers).'))
    url = TextField(lazy_gettext('School URL'), [
        validators.Length(min=6, max=200),
        validators.URL(),
        validators.Required()
    ],
                    description=lazy_gettext('Address of your school.'))
    user_full_name = TextField(
        lazy_gettext('User name'),
        [validators.Required(),
         validators.Length(min=4)] + forms.USER_FULL_NAME_VALIDATORS,
        description=lazy_gettext('Your name and last name.'))
    user_login = TextField(lazy_gettext('Login'), [validators.Required()] +
                           forms.USER_LOGIN_DEFAULT_VALIDATORS,
                           description=lazy_gettext(
                               'Your new login (you can create more later).'))
    user_password = PasswordField(
        lazy_gettext('Password'),
        [validators.Required()] + forms.USER_PASSWORD_DEFAULT_VALIDATORS,
        description=lazy_gettext('Your access password.'))
示例#3
0
class job_form(Form):
    vcf = FileField(u'VCF File', [
        make_optional('uri'),
        validators.required(message=u'You need to supply a VCF file')
    ])
    uri = TextField(u'VCF URI', [
        make_optional('vcf'),
        validators.URL(
            message=
            u'You must specify a valid URI (e.g. "localhost" is not allowed)')
    ])

    min_variant_quality = IntegerField(u'Minimum Variant Quality',
                                       [validators.NumberRange(min=0, max=99)],
                                       default=30)
    min_quality_depth = IntegerField(u'Minimum Quality by Depth',
                                     [validators.NumberRange(min=0)],
                                     default=10)
    homozyg_window_size = IntegerField(u'Homozygosity Window Size',
                                       [validators.NumberRange(min=0)],
                                       default=1000)
    heterozyg_calls = IntegerField(u'Heterozygous Calls allowed in window',
                                   [validators.NumberRange(min=0)],
                                   default=10)

    def validate_vcf(form, field):
        m = re.match(
            '^.*\.(' + '|'.join(app.config['UPLOAD_FORMAT_EXTENSIONS']) + ')$',
            field.data.filename, re.IGNORECASE)
        if not m:
            raise ValidationError(
                u'You must upload a VCF file (compressed or uncompressed)')
示例#4
0
class MarkForm(Form):
    referrer = HiddenField([validators.URL(require_tld=False)])
    title = TextField('Title',
                      [validators.Length(min=0, max=255)],
                      filters=[strip_filter])
    url = TextField('URL',
                    [validators.Length(min=4, max=512),
                     validators.URL(require_tld=False,
                                    message='Not a valid URL')],
                    filters=[strip_filter])
    type = RadioField('Type',
                      coerce=unicode,
                      choices=[('bookmark', 'Bookmark'), ('feed', 'Feed')],
                      default='bookmark')
    tags = TextField('Tags',
                     [validators.Length(min=0, max=255)],
                     filters=[strip_filter])
示例#5
0
文件: user.py 项目: sandeepraju/fbone
class ProfileForm(Form):
    next = HiddenField()
    name = TextField(_('Username'))
    email = TextField(_('email'), [validators.Email()])
    website = TextField(_('URL'), [validators.URL()])
    location = TextField(_('Location'), [validators.Length(max=100)])
    bio = TextAreaField(_('bio'), [validators.Length(max=200)])
    submit = SubmitField(_('Save'))
示例#6
0
class BookmarkForm(Form):
    title = TextField('title', [validators.Length(min=0, max=255)],
                      filters=[strip_filter])
    url = TextField('url', [
        validators.Length(min=4, max=512),
        validators.URL(require_tld=False, message='Not a valid URL')
    ],
                    filters=[strip_filter])
    tags = TextField('tags', [validators.Length(min=0, max=255)],
                     filters=[strip_filter])
示例#7
0
class AddForm(RetrospectiveForm):

    name = TextField(lazy_gettext('Name'),
                     validators=[validators.Required()],
                     default='RLMS name',
                     description=lazy_gettext("Name of the RLMS"))
    url = TextField(
        lazy_gettext('URL'),
        validators=[validators.URL(require_tld=False),
                    validators.Required()],
        default='http://rlms-address/',
        description=lazy_gettext('Main URL of the RLMS'))
    location = TextField(
        lazy_gettext('Location'),
        validators=[validators.Required()],
        default='City, Country',
        description=lazy_gettext("City and country where the RLMS is hosted"))
    publicly_available = BooleanField(
        lazy_gettext('Public'),
        default=False,
        description=lazy_gettext(
            "Do you want to provide access to this laboratory publicly?"))
    public_identifier = TextField(
        lazy_gettext('Public identifier'),
        default='',
        description=lazy_gettext(
            "If publicly available, under what identifier?"))
    default_autoload = BooleanField(
        lazy_gettext('Autoload'),
        default=False,
        description=lazy_gettext("Should these labs be loaded by default?"))

    def __init__(self, **kwargs):
        default_name = getattr(
            self, 'DEFAULT_NAME',
            getattr(self, 'DEFAULT_PUBLIC_IDENTIFIER', None))
        if default_name:
            kwargs.setdefault('name', default_name)

        default_location = getattr(self, 'DEFAULT_LOCATION', None)
        if default_location:
            kwargs.setdefault('location', default_location)

        default_url = getattr(self, 'DEFAULT_URL', None)
        if default_url:
            kwargs.setdefault('url', default_url)

        default_publicly_available = getattr(self,
                                             'DEFAULT_PUBLICLY_AVAILABLE',
                                             None)
        if default_publicly_available is not None:
            kwargs.setdefault('publicly_available', default_publicly_available)

        default_public_identifier = getattr(self, 'DEFAULT_PUBLIC_IDENTIFIER',
                                            '')
        if default_public_identifier:
            kwargs.setdefault('public_identifier', default_public_identifier)

        default_autoload = getattr(self, 'DEFAULT_AUTOLOAD', None)
        if default_autoload is not None:
            kwargs.setdefault('default_autoload', default_autoload)

        super(AddForm, self).__init__(**kwargs)