Exemple #1
0
class SettingsForm(BaseForm):

    width = fields.IntegerField('width',
                                validators=[validators.NumberRange(min=0)])

    height = fields.IntegerField('width',
                                 validators=[validators.NumberRange(min=0)])

    resample = fields.StringField(
        'resample',
        validators=[
            validators.Optional(),
            validators.AnyOf(['NEAREST', 'BILINEAR', 'BICUBIC', 'LANCZOS'])
        ])
Exemple #2
0
class AddForm(BaseForm):

    name = fields.StringField('Name',
                              validators=[
                                  validators.Required(),
                                  validators.UniqueDocument(
                                      Account, case_sensitive=False)
                              ])

    api_rate_limit_per_second = fields.IntegerField(
        'Rate limit (per second)', validators=[validators.Optional()])

    api_allowed_ip_addresses = fields.StringListField(
        'Allowed IP addresses', validators=[validators.Optional()])

    def validate_api_rate_limit_per_second(form, field):

        if field.data and field.data < 1:
            raise validators.ValidationError(
                'The rate limit must be set to 1 or more')

    def validate_api_allowed_ip_addresses(form, field):

        for ip_address in field.data:
            try:
                ipaddress.ip_address(ip_address)
            except ValueError:
                raise validators.ValidationError('Not a valid IP address: ' +
                                                 ip_address)
Exemple #3
0
class PaginationForm(BaseForm):

    after = fields.HiddenField(coerce=form_utils.to_object_id)

    before = fields.HiddenField(coerce=form_utils.to_object_id)

    limit = fields.IntegerField(
        'Limit',
        validators=[validators.NumberRange(1, 100)],
        default=10
    )
Exemple #4
0
class ListForm(BaseForm):

    page = fields.IntegerField('Page', default=1)

    q = fields.StringField('Search')

    sort_by = fields.SelectField('Sort by',
                                 choices=sort_by_choices([('created',
                                                           'Created')]),
                                 default='-created')

    filters = fields.FormField(Filters)
Exemple #5
0
class SettingsForm(BaseForm):

    max_colors = fields.IntegerField('max_colors',
                                     validators=[
                                         validators.Optional(),
                                         validators.NumberRange(min=1, max=32)
                                     ],
                                     default=8)

    min_weight = fields.FloatField('min_weight',
                                   validators=[
                                       validators.Optional(),
                                       validators.NumberRange(min=0, max=1)
                                   ],
                                   default=0.015)

    max_sample_size = fields.IntegerField(
        'max_colors',
        validators=[validators.Optional(),
                    validators.NumberRange(min=0)],
        default=512)
Exemple #6
0
class ListForm(BaseForm):

    page = fields.IntegerField('Page', default=1)

    q = fields.StringField('Search')

    sort_by = fields.SelectField(
        'Sort by',
        choices=sort_by_choices([
            ('name', 'Name')
        ]),
        default='name'
    )
Exemple #7
0
class PutForm(BaseForm):

    name = fields.StringField(
        'name',
        validators=[validators.Optional()]
    )

    expire = fields.IntegerField(
        'expire',
        validators=[
            validators.Optional(),
            validators.NumberRange(min=1)
        ]
    )

    secure = fields.BooleanField('secure')
Exemple #8
0
class SettingsForm(BaseForm):

    image_format = fields.StringField(
        'image_format',
        validators=[
            validators.Required(),
            validators.AnyOf(IMAGE_FORMATS.keys())
        ]
    )

    quality = fields.IntegerField(
        'quality',
        validators=[
            validators.Optional(),
            validators.NumberRange(min=0, max=100)
        ],
        default=80
    )

    lossless = fields.BooleanField('lossless')

    progressive = fields.BooleanField('progressive')

    versioned = fields.BooleanField('versioned')
Exemple #9
0
class ExpireForm(BaseForm):

    seconds = fields.IntegerField(
        'seconds',
        validators=[validators.NumberRange(min=0)]
    )
Exemple #10
0
class SettingsForm(BaseForm):

    frame_number = fields.IntegerField('frame_number',
                                       validators=[validators.Optional()],
                                       default=0)
Exemple #11
0
class SettingsForm(BaseForm):

    degrees = fields.IntegerField(
        'angle',
        validators=[validators.Required(),
                    validators.AnyOf([90, 180, 270])])