class NetworkUpload(FlaskForm): design_files = MultipleFileField('Upload Pipe Design Files', id='design_input') design_hgl_toggle = BooleanField('Display HGL Elevations') design_submit = SubmitField('Format Pipe Design Files') velocity_files = MultipleFileField('Upload Pipe Velocity Files', id='velocity_input') velocity_fps_toggle = BooleanField('Highlight Velocities') velocity_submit = SubmitField('Format Pipe Velocity Files') spread_files = MultipleFileField('Upload Gutter Spread Files', id='spread_input') spread_bypass_toggle = BooleanField('Display Bypass Data') spread_submit = SubmitField('Format Gutter Spread Files')
class MProductForm(FlaskForm): name = StringField('Product name', validators=[InputRequired(), Length(1, 64)]) images = MultipleFileField( 'Product Images', validators=[InputRequired(), FileAllowed(images, 'Images only!')]) description = TextAreaField('Description', [InputRequired()]) categories = QuerySelectMultipleField( 'Categories', validators=[InputRequired()], get_label='name', query_factory=lambda: db.session.query(MCategory).order_by('order')) availability = BooleanField(u'Is it currently available?') min_order_quantity = IntegerField('Min number of units per order e.g 1', default=1) length = FloatField('Length in numbers only e.g 0.99') weight = FloatField('Weight in numbers only e.g 0.21') height = FloatField('Height in numbers only e.g 10') price = FloatField('Price, Figures only e.g 16.99') seller = QuerySelectField('Seller', validators=[InputRequired()], get_label='full_name', query_factory=lambda: db.session.query(User). filter_by(is_seller=True).order_by('first_name')) price_currency = QuerySelectField( 'Price currency', validators=[InputRequired()], get_label='name', query_factory=lambda: db.session.query(MCurrency).order_by('name')) is_featured = BooleanField("Is Featured ?") lead_time = StringField('Delivery time') submit = SubmitField('Submit')
class ProjectForm(FlaskForm): projectName = StringField( 'Project Name', validators=[InputRequired(), Length(min=5, max=30)]) projectDescription = TextAreaField('Project Description', validators=[Length(min=0, max=200)]) files = MultipleFileField('test files', validators=[InputRequired()])
class ModuleCrudForm(BaseModelForm): """Client Form .""" name = StringField("Name", validators=[DataRequired(), Length(min=5, max=80)]) description = StringField( "Description", validators=[DataRequired(), Length(min=5, max=256)]) long_description = TextAreaField( "Long Description", validators=[DataRequired(), Length(min=5)]) tags = StringField("Tags (comma separated)", validators=[DataRequired(), Length(min=5)]) demo_url = StringField("Demo Url", validators=[DataRequired(), Length(min=5, max=256)]) code_path = StringField( "Code Path", validators=[DataRequired(), Length(min=5, max=256)]) price = FloatField("Price", validators=[DataRequired()]) support_price = FloatField("Support Price", validators=[DataRequired()]) release_date = DateField("Release Date", validators=[DataRequired()]) last_update_date = DateField("Release Date", validators=[DataRequired()]) image = FileField('Product Image (397x306)', validators=[ FileRequired(), FileAllowed(images, 'Images only allowed!') ]) images = MultipleFileField( 'Product Screenshots (726x403)', validators=[DataRequired(), FileAllowed(images, 'Images only!')])
class NewMessageForm(FlaskForm): class Meta: csrf = False id = HiddenField("ticket_id", [DataRequired()]) message = StringField("Message") files = MultipleFileField("Attach file") submit_btn = SubmitField("Submit")
class AddImgForm(FlaskForm): # should use InputRequired() not DataRequired() # Need to add custom validator for multiple file extensions. FileAllowed does not work. Maybe due to wtforms vs flask_wtf...... images = MultipleFileField('Upload Images', validators=[ InputRequired(), FileAllowed( ['jpg', 'png', 'jpeg', 'tif', 'bmp']) ]) submitBTN2 = SubmitField('Upload')
class UpdatePropertyForm(CreatePropertyForm): photos = MultipleFileField( "Upload photos of your property", ) def validate_photos(self, photos): for file in photos.data: if not file.filename.endswith(("jpg", "jpeg", "png",)): raise ValidationError("Only Images are allowed e.g jpg, jpeg, png") submit = SubmitField("Update")
class ValidationForm(FlaskForm): metadata_file = \ MultipleFileField(\ 'Metadata csv file(s)', validators=[DataRequired(),FileAllowed(['csv'])]) samplesheet_file = \ FileField(\ 'Samplesheet csv file', validators=[FileAllowed(['csv']),FileRequired()]) recaptcha = RecaptchaField() submit = SubmitField('Validate metadata')
class PostForm(FlaskForm): title = StringField('Title', validators=[DataRequired()]) # content = TextAreaField('Content', validators=[DataRequired()]) content = CKEditorField('Content', validators=[DataRequired()]) tag = StringField('Tag') fileResource = MultipleFileField( 'Upload Resources', validators=[ MultiFileAllowed(['jpg', 'png', 'pdf', 'xlsx', 'txt']), FileSizeLimit(max_size_in_mb=4) ]) submit = SubmitField('Post')
class FileForm(FlaskForm): algo = SelectField('Choose Algorithm', choices=[('Wordfreq', 'Word Frequency'), ('TextRank', 'Text Rank'), ('TF_IDF', 'TF_IDF')]) files = MultipleFileField('File(s)', validators=[ InputRequired(), MultiFileAllowed( ['pdf', 'doc', 'txt', 'epub']) ]) sentences = IntegerField('Number of sentences', validators=[DataRequired()]) submit = SubmitField('Submit')
class UploadKitFilesForm(FlaskForm): files = MultipleFileField('Add more files', validators=[DataRequired()], description='You can upload up to 50 MB.') submit = SubmitField('Upload') def validate_files(self, files): for file in files.data: if not allowed_file(file.filename): raise ValidationError('That file type is not supported.') if len(file.filename) > 30: raise ValidationError( f'The length of one of your file\'s names, particularly "{file.filename}", is too long.' )
class UploadM3uForm(FlaskForm): AVAILABLE_STREAM_TYPES_FOR_UPLOAD = [(constants.StreamType.PROXY, 'Proxy Stream'), (constants.StreamType.VOD_PROXY, 'Proxy Vod'), (constants.StreamType.RELAY, 'Relay'), (constants.StreamType.ENCODE, 'Encode'), (constants.StreamType.CATCHUP, 'Catchup'), (constants.StreamType.TEST_LIFE, 'Test life'), (constants.StreamType.VOD_RELAY, 'Vod relay'), (constants.StreamType.VOD_ENCODE, 'Vod encode'), (constants.StreamType.COD_RELAY, 'Cod relay'), (constants.StreamType.COD_ENCODE, 'Cod encode'), (constants.StreamType.EVENT, 'Event')] files = MultipleFileField() type = SelectField(lazy_gettext(u'Type:'), coerce=constants.StreamType.coerce, validators=[InputRequired()], choices=AVAILABLE_STREAM_TYPES_FOR_UPLOAD, default=constants.StreamType.RELAY) upload = SubmitField(lazy_gettext(u'Upload'))
class CreatePropertyForm(FlaskForm): name = StringField( "Property Name", validators=[DataRequired(), Length(min=5, max=50)] ) desc = TextAreaField( "Property Description", validators=[DataRequired(), Length(min=10, max=300)] ) type = SelectField( "Property For ...", choices=[ "Select", "Rent", "Sale", ], validators=[DataRequired()], ) photos = MultipleFileField( "Upload photos of your property", validators=[ DataRequired(), Length( min=1, max=10, message="Upload 1 or more photos and not more that 10" ), ], ) price = StringField("Price", validators=[DataRequired(), Length(min=1, max=50)]) location = StringField( "Property Location", validators=[DataRequired(), Length(min=2, max=50)] ) submit = SubmitField("Create") def validate_photos(self, photos): for file in photos.data: if not file.filename.endswith(("jpg", "jpeg", "png",)): raise ValidationError("Only Images are allowed e.g jpg, jpeg, png") def validate_type(self, type): """ Checks if the user has selected gender either Male or Female from the Select Field. """ if type.data == "Select": raise ValidationError("You need to select your property listing type.")
class KitchenSinkForm(FlaskForm): string_field = StringField( "StringField", widget=GovTextInput(), validators=[InputRequired(message="StringField is required")], ) email_field = StringField( "Email address", widget=GovTextInput(), validators=[ InputRequired(message="Email address is required"), Email() ], ) float_field = FloatField( "FloatField", widget=GovTextInput(), validators=[InputRequired(message="FloatField is required")], ) integer_field = IntegerField( "IntegerField", widget=GovTextInput(), validators=[InputRequired(message="IntegerField is required")], ) decimal_field = DecimalField( "DecimalField", widget=GovTextInput(), validators=[InputRequired(message="DecimalField is required")], ) textarea_field = TextAreaField( "TextAreaField", widget=GovTextArea(), validators=[InputRequired(message="TextAreaField is required")], ) boolean_field = BooleanField( "BooleanField", widget=GovCheckboxInput(), validators=[InputRequired(message="Please tick the box")], ) select_field = SelectField( "SelectField", widget=GovSelect(), validators=[InputRequired(message="Please select an option")], choices=[ ("", "Please select"), ("one", "One"), ("two", "Two"), ("three", "Three"), ], default="", ) select_multiple_field = SelectMultipleField( "SelectMultipleField", widget=GovCheckboxesInput(), validators=[InputRequired(message="Please select an option")], choices=[("one", "One"), ("two", "Two"), ("three", "Three")], ) radio_field = RadioField( "RadioField", widget=GovRadioInput(), validators=[InputRequired(message="Please select an option")], choices=[("one", "One"), ("two", "Two"), ("three", "Three")], ) file_field = FileField( "FileField", widget=GovFileInput(), validators=[InputRequired(message="Please upload a file")], ) multiple_file_field = MultipleFileField( "MultipleFileField", widget=GovFileInput(multiple=True), validators=[InputRequired(message="Please upload a file")], ) password_field = PasswordField( "PasswordField", widget=GovPasswordInput(), validators=[ InputRequired("Password is required"), EqualTo( "password_retype_field", message="Please ensure both password fields match", ), ], ) password_retype_field = PasswordField( "Re-type your password", widget=GovPasswordInput(), validators=[InputRequired("Please retype your password")], ) submit_button = SubmitField("SubmitField", widget=GovSubmitInput())
class ExampleForm(FlaskForm): string_field = StringField( "StringField", widget=GovTextInput(), validators=[InputRequired(message="StringField is required")], description="StringFieldHint", ) date_field = DateField( "DateField", format="%d %m %Y", widget=GovDateInput(), validators=[InputRequired(message="Date is required")], description="DateFieldHint", ) date_field_default = DateField( "DateField", default=datetime.datetime(day=23, month=11, year=2020), format="%d %m %Y", widget=GovDateInput(), validators=[InputRequired(message="Date is required")], description="DateFieldHint", ) email_field = StringField( "EmailField", widget=GovTextInput(), validators=[ InputRequired(message="EmailField is required"), Email(message="Email is not valid"), ], description="EmailFieldHint", ) float_field = FloatField( "FloatField", widget=GovTextInput(), validators=[InputRequired(message="FloatField is required")], description="FloatFieldHint", ) integer_field = IntegerField( "IntegerField", widget=GovTextInput(), validators=[InputRequired(message="IntegerField is required")], description="IntegerFieldHint", ) decimal_field = DecimalField( "DecimalField", widget=GovTextInput(), validators=[InputRequired(message="DecimalField is required")], description="DecimalFieldHint", ) textarea_field = TextAreaField( "TextAreaField", widget=GovTextArea(), validators=[InputRequired(message="TextAreaField is required")], description="TextAreaFieldHint", ) charactercount_field = TextAreaField( "CharacterCountField", widget=GovCharacterCount(), validators=[InputRequired(message="CharacterCountField is required")], description="CharacterCountFieldHint", ) boolean_field = BooleanField( "BooleanField", widget=GovCheckboxInput(), validators=[InputRequired(message="Please tick the box")], description="BooleanFieldHint", ) select_field = SelectField( "SelectField", widget=GovSelect(), validators=[InputRequired(message="Please select an option")], choices=[ ("", "Please select"), ("one", "One"), ("two", "Two"), ("three", "Three"), ], default="", description="SelectFieldHint", ) select_multiple_field = SelectMultipleField( "SelectMultipleField", widget=GovCheckboxesInput(), validators=[InputRequired(message="Please select an option")], choices=[("one", "One"), ("two", "Two"), ("three", "Three")], description="SelectMultipleFieldHint", ) radio_field = RadioField( "RadioField", widget=GovRadioInput(), validators=[InputRequired(message="Please select an option")], choices=[("one", "One"), ("two", "Two"), ("three", "Three")], description="RadioFieldHint", ) file_field = FileField( "FileField", widget=GovFileInput(), validators=[InputRequired(message="Please upload a file")], description="FileFieldHint", ) multiple_file_field = MultipleFileField( "MultipleFileField", widget=GovFileInput(multiple=True), validators=[InputRequired(message="Please upload a file")], description="MultipleFileFieldHint", ) password_field = PasswordField( "PasswordField", widget=GovPasswordInput(), validators=[ InputRequired("Password is required"), EqualTo( "password_retype_field", message="Please ensure both password fields match", ), ], description="PasswordFieldHint", ) password_retype_field = PasswordField( "Re-type your password", widget=GovPasswordInput(), validators=[InputRequired("Please retype your password")], description="PasswordFieldHint", ) nested_form = FieldList( FormField(ExampleChildForm), min_entries=1, ) submit_button = SubmitField("SubmitField", widget=GovSubmitInput()) def validate_string_field(self, field): if field.data != "John Smith": raise ValidationError( 'Example serverside error - type "John Smith" into this field to suppress it' )
class F(Form): files = MultipleFileField()
class ExampleForm(FlaskForm): string_field = StringField( 'StringField', widget=GovTextInput(), validators=[InputRequired(message='StringField is required')], ) email_field = StringField( 'Email address', widget=GovTextInput(), validators=[ InputRequired(message='Email address is required'), Email() ]) float_field = FloatField( 'FloatField', widget=GovTextInput(), validators=[InputRequired(message='FloatField is required')]) integer_field = IntegerField( 'IntegerField', widget=GovTextInput(), validators=[InputRequired(message='IntegerField is required')]) decimal_field = DecimalField( 'DecimalField', widget=GovTextInput(), validators=[InputRequired(message='DecimalField is required')]) textarea_field = TextAreaField( 'TextAreaField', widget=GovTextArea(), validators=[InputRequired(message='TextAreaField is required')]) boolean_field = BooleanField( 'BooleanField', widget=GovCheckboxInput(), validators=[InputRequired(message='Please tick the box')]) select_field = SelectField( 'SelectField', widget=GovSelect(), validators=[InputRequired(message='Please select an option')], choices=[('', 'Please select'), ('one', 'One'), ('two', 'Two'), ('three', 'Three')], default='') select_multiple_field = SelectMultipleField( 'SelectMultipleField', widget=GovCheckboxesInput(), validators=[InputRequired(message='Please select an option')], choices=[('one', 'One'), ('two', 'Two'), ('three', 'Three')]) radio_field = RadioField( 'RadioField', widget=GovRadioInput(), validators=[InputRequired(message='Please select an option')], choices=[('one', 'One'), ('two', 'Two'), ('three', 'Three')]) file_field = FileField( 'FileField', widget=GovFileInput(), validators=[InputRequired(message='Please upload a file')]) multiple_file_field = MultipleFileField( 'MultipleFileField', widget=GovFileInput(multiple=True), validators=[InputRequired(message='Please upload a file')]) password_field = PasswordField( 'PasswordField', widget=GovPasswordInput(), validators=[ InputRequired('Password is required'), EqualTo('password_retype_field', message='Please ensure both password fields match'), ]) password_retype_field = PasswordField( 'Re-type your password', widget=GovPasswordInput(), validators=[InputRequired('Please retype your password')]) submit_button = SubmitField('SubmitField', widget=GovSubmitInput()) def validate_string_field(self, field): if field.data != 'John Smith': raise ValidationError( 'Example serverside error - type "John Smith" into this field to suppress it' )
class UploadFileForm(Form): uploaded_files = MultipleFileField("Select: ")
class NewTicketForm(FlaskForm): subject = StringField("Subject", [DataRequired()]) files = MultipleFileField("Attach file") description = TextAreaField("Description", [DataRequired()]) submit_btn = SubmitField("Submit")