class SVGFileUpload(StripWhitespaceForm):
    file = FileField_wtf(
        'Upload an SVG logo',
        validators=[
            FileAllowed(['svg'], 'SVG Images only!'),
            DataRequired(message="You need to upload a file to submit")
        ]
    )
class PDFUploadForm(StripWhitespaceForm):
    file = FileField_wtf(
        'Upload a letter in PDF format to check if it fits in the printable area',
        validators=[
            FileAllowed(['pdf'], 'PDF documents only!'),
            DataRequired(message="You need to upload a file to submit")
        ]
    )
Esempio n. 3
0
class ServiceCreateEmailBranding(StripWhitespaceForm):

    name = StringField('Name')
    colour = StringField(
        'Colour',
        render_kw={'onchange': 'update_colour(this)'},
        validators=[
            Regexp(regex="^$|^#(?:[0-9a-fA-F]{3}){1,2}$", message='Must be a valid color hex code')
        ]
    )
    file = FileField_wtf('Upload a PNG logo', validators=[FileAllowed(['png'], 'PNG Images only!')])
Esempio n. 4
0
class ServiceManageOrg(StripWhitespaceForm):

    name = StringField('Name')

    colour = StringField('Colour',
                         render_kw={
                             'onkeyup': 'update_colour_span()',
                             'onblur': 'update_colour_span()'
                         })
    file = FileField_wtf('Upload a PNG logo',
                         validators=[FileAllowed(['png'], 'PNG Images only!')])
class ServiceUpdateEmailBranding(StripWhitespaceForm):
    name = StringField('Name of brand')
    text = StringField('Text')
    colour = StringField(
        'Colour',
        validators=[
            Regexp(regex="^$|^#(?:[0-9a-fA-F]{3}){1,2}$", message='Must be a valid color hex code (starting with #)')
        ]
    )
    file = FileField_wtf('Upload a PNG logo', validators=[FileAllowed(['png'], 'PNG Images only!')])
    brand_type = RadioField(
        "Brand type",
        choices=[
            ('both', 'Notication and branding'),
            ('org', 'Branding only'),
            ('org_banner', 'Branding banner'),
            ('no_branding', 'No branding'),
        ]
    )

    def validate_name(form, name):
        op = request.form.get('operation')
        if op == 'email-branding-details' and not form.name.data:
            raise ValidationError('This field is required')