示例#1
0
class UploadVideoForm(FlaskForm):
    title = wtf.StringField(
        'title',
        validators=[wtf.validators.DataRequired()]
    )
    description = wtf.TextAreaField(
        'description',
        validators=[wtf.validators.DataRequired()]
    )
    price = wtf.DecimalField(
        'price',
        validators=[wtf.validators.DataRequired()]
    )
    labels = wtf.StringField(
        'labels',
        validators=[wtf.validators.DataRequired()]
    )
    video_file = fwtff.FileField(
        'vfile',
        validators=[
            fwtff.FileRequired(),
            fwtff.FileAllowed(['mp4'])
        ]
    )
    submit = wtf.SubmitField('submit')
示例#2
0
class CarSketchForm(FlaskForm):
    sketch = file.FileField('Файл скетчу',
                            validators=[
                                file.FileRequired(),
                                file.FileAllowed([
                                    'ino',
                                ], 'Тільки файли з розшренням .ino!')
                            ])
    submit = wtforms.SubmitField('Відправити')
示例#3
0
文件: form.py 项目: washim/GorillaML
class RegisterSiteConfigForm(FlaskForm):
    site_name = StringField('Site name', [validators.DataRequired()])
    site_slogan = StringField('Site slogan', [validators.DataRequired()])
    site_logo = file.FileField(
        'Site logo', [file.FileAllowed(['png', 'jpeg', 'jpg', 'gif'])])
    page_title = StringField('Page title', [validators.DataRequired()])
    login_redirect = StringField('Login redirect', [validators.DataRequired()])
    copyrights = StringField('Copyrights footer')
    submit = SubmitField('Save')
示例#4
0
class UploadForm(FlaskForm):
    save = FileField('Your save file', [
        file.FileRequired(),
        file.FileAllowed(
            savefiles,
            'Only .user files or .zip or .gz compressed uploads allowed')
    ])
    upload_all = RadioField('Upload all?',
                            choices=[
                                (1, 'Upload all solutions'),
                                (0, 'Let me choose which solutions to upload')
                            ],
                            default=1,
                            coerce=int)
    submit = SubmitField('Upload')
示例#5
0
class EditProfileForm(FlaskForm):

    first_name = wtforms.StringField(label="Nombre")
    last_name = wtforms.StringField(label="Apellido")
    email = wtforms.StringField(
        label="correo electronico",
        validators=[
            validators.email("Correo no valido"),
            EmailUniqueness("Correo electronico ya registrado, ingrese otro"),
        ],
    )
    location = wtforms.StringField(label="location")
    gender = wtforms.SelectField(
        label="Genero",
        choices=[("nulo", "--"), ("hombre", "Hombre"), ("mujer", "Mujer")],
    )
    information = wtforms.TextAreaField(label="Informacion")
    avatar_file = file.FileField(validators=[
        file.FileAllowed(photos,
                         "Archivo no valido, debe ser una imagen valida")
    ])
class UpdateAccountForm(flask_wtf.FlaskForm):
    """Class representing the account update form for the application

    Parameters
    ----------
    FlaskForm : WTForms

        Flask wtf class that is extended to create the user login form
    """

    username = wtforms_core.StringField(
        "Username",
        validators=[
            wtforms.validators.DataRequired(),
            wtforms.validators.Length(min=2, max=20),
        ],
    )
    email = wtforms_core.StringField(
        "Email",
        validators=[
            wtforms.validators.DataRequired(),
            wtforms.validators.Email(),
        ],
    )
    picture = flask_file.FileField(
        "Update profile picture",
        validators=[flask_file.FileAllowed(["jpg", "png"])],
    )
    submit = wtforms_simple.SubmitField("Update")

    def validate_username(self, username):
        """Validate if the given username is still available against the DB

        Parameters
        ----------
        username : string

            Username as entered in the form.
        """
        if username.data != flask_login.current_user.username:
            user = flaskblog_user.User.query.filter_by(
                username=username.data
            ).first()
            if user:
                raise wtforms.validators.ValidationError(
                    "That username is taken. Please choose a different one"
                )

    def validate_email(self, email):
        """Validate if the given email is still available against the DB

        Parameters
        ----------
        email : string

            email as entered in the form.
        """
        if email.data != flask_login.current_user.email:
            user = flaskblog_user.User.query.filter_by(
                email=email.data
            ).first()
            if user:
                raise wtforms.validators.ValidationError(
                    "That email address is taken. Please choose a different one"
                )
示例#7
0
class ModifyMemberForm(ModifyForm):
    cell = wtforms.TextField('Cell Phone')
    birthday = wtforms.TextField('Birthday')
    cycle = wtforms.IntegerField('Cycle')
    addr = wtforms.TextField('Address')
    photo = wtf_file.FileField(
        'Photo',
        validators=[
            wtf_file.FileAllowed(['png', 'jpg', 'gif'],
                                 'PNG/JPG/GIF file only')
        ])
    cover = wtf_file.FileField(
        'Cover',
        validators=[
            wtf_file.FileAllowed(['png', 'jpg', 'gif'],
                                 'PNG/JPG/GIF file only')
        ])
    department = wtforms.IntegerField('Department')
    stem_department = wtforms.IntegerField('STEM_Department')
    cvpublic = wtforms.TextField('CV')
    cvmember = wtforms.TextField('Comment')
    social = wtforms.TextField('Social Network')
    position = wtforms.TextField('Position')

    def validate(self):
        rv = super().validate()
        if not rv:
            return False

        if self.cell.data:
            self.user.phone = self.cell.data
        if self.birthday.data:
            self.user.birthday = datetime.datetime.strptime(
                self.birthday.data, '%Y-%m-%d').date()
        if self.photo.data.filename:
            ext = self.photo.data.filename.rsplit('.', 1)[1]
            filename = 'profile/%d.' % self.user.id + ext
            file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
            self.photo.data.save(file_path)
            self.user.img = filename
        if self.cover.data.filename:
            ext = self.cover.data.filename.rsplit('.', 1)[1]
            filename = 'cover/%d.' % self.user.id + ext
            file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
            self.cover.data.save(file_path)
            self.user.cover = filename
        if self.cycle.data:
            self.user.cycle = self.cycle.data

        self.user.addr = self.addr.data

        self.user.cvpublic = self.cvpublic.data

        self.user.cvmember = self.cvmember.data

        if self.social.data:
            if self.social.data[0:4] != 'http':
                self.social.data = 'http://' + self.social.data

        self.user.social = self.social.data

        self.user.position = self.position.data

        self.user.last_mod = datetime.datetime.now()

        self.user.deptuniv_id = self.department.data
        self.user.deptstem_id = self.stem_department.data

        db.session.commit()

        target = models.User.query.filter_by(
            id=flask_login.current_user.id).first()
        notification.Push(self.user,
                          models.User.query.filter_by(ismember=1).all(),
                          target, models.NotificationAction.update)

        return True
示例#8
0
文件: form.py 项目: washim/GorillaML
class PluginUploadForm(FlaskForm):
    upload = file.FileField('Choose your addon file', [
        file.FileRequired(),
        file.FileAllowed(['zip'], 'Zip file only!'), plugin_validate
    ])
    submit = SubmitField('Upload')