Exemple #1
0
class WordifyForms(FlaskForm):

    # file browser
    file = FileField(validators=[
        FileRequired("blabla"),
        FileAllowed(app.config["ALLOWED_EXTENSIONS"], "Excel files only!"
                    ),  # this check is performed in javascript
    ])

    # language drop-down
    language = SelectField(
        "Language",
        coerce=str,
        choices=[(shortcut, name[0].title())
                 for shortcut, name in LANG_FULL.items()],
    )

    # email field
    email = StringField(
        "Email",
        validators=[DataRequired("Please enter a valid email address.")],
    )

    iterations = FloatField(validators=[DataRequired()], default=100)
    threshold = FloatField(validators=[DataRequired()], default=0.3)

    # submit button
    submit = SubmitField("Submit")
Exemple #2
0
class EditPictureForm(FlaskForm):
    description = TextAreaField('description', validators=[DataRequired()])
    shot_time = DateField('shot_time', validators=[])
    place = StringField('place', validators=[])
    tags = SelectField(choices=tag_choices, validators=[DataRequired()])
    submit = SubmitField('Update') # handle update function
    delete = SubmitField('Delete') # handle delete function
Exemple #3
0
class PictureForm(FlaskForm):
    description = TextAreaField('description', validators=[DataRequired()])
    shot_time = DateField('shot time', validators=[])
    place = StringField('place', validators=[])
    tags = SelectField(choices=tag_choices, validators=[DataRequired()])
    file = FileField('File', validators=[FileRequired(),
                     FileAllowed(file_allowed)])
    submit = SubmitField('upload')
Exemple #4
0
class RegistFrom(FlaskForm):
    telephone = StringField('电话号码', validators=[DataRequired(), Length(1, 11)])
    username = StringField('用户名', validators=[DataRequired(), Length(1, 20)])
    password = PasswordField('密码', validators=[DataRequired(), Length(1, 128)])
    password2 = PasswordField(
        '确认密码', validators=[DataRequired(),
                            EqualTo('password2')])
    submit = SubmitField('注册')
Exemple #5
0
class ChangePasswordForm(FlaskForm):
    password = PasswordField(
        'password', validators=[DataRequired(),
                                Length(min=8, max=255)])
    confirm = PasswordField('Repeat password',
                            validators=[
                                DataRequired(),
                                EqualTo('password',
                                        message='Passwords must match.')
                            ])
Exemple #6
0
class HomeForm(FlaskForm):
    first_name_field = StringField('Enter your name:',
                                   validators=[DataRequired(), Length(min=2, max=30)])
    first_raw_coordinates = FileField('Upload your JSON file  ',
                                      validators=[FileRequired(), FileAllowed(['json'], 'Just Google\'s json!')])

    second_name_field = StringField('Enter your friend\'s name:',
                                    validators=[DataRequired(), Length(min=2, max=30)])
    second_raw_coordinates = FileField('Upload your friend\'s JSON file ',
                                       validators=[FileRequired(), FileAllowed(['json'], 'Just Google\'s json!')])

    distance_limit_in_m = IntegerField('Distance limit (in meters):', default=1000)
    time_limit_in_h = IntegerField('Time limit (in hours):', default=24)

    submit_button = SubmitField('Find crossed roads!')
Exemple #7
0
class UploadForm(FlaskForm):
    description = TextAreaField('Message', validators=[DataRequired()])
    photo = FileField('Photo',
                      validators=[
                          FileRequired(),
                          FileAllowed(['jpg', 'png', 'jpeg'], 'Images only!')
                      ])
Exemple #8
0
class AnalyzeForm(FlaskForm):
    picture = FileField(
        "Upload image",
        validators=[FileAllowed(["jpg", "png"]),
                    DataRequired()],
    )
    submit = SubmitField("Analyze")
class EMSForm(FlaskForm):
    incident_number = IntegerField('Incident Number', [validators.required()])
    #unit_id = IntegerField('Unit ID', [validators.required()])
    incident_date = DateTimeField(label='Incident Date',
                                  validators=[validators.InputRequired()],
                                  format="%d%b%Y %H:%M",
                                  default=None)
    incident_address = StringField('Incident Address',
                                   [validators.Length(min=1, max=100)])
    incident_city = StringField('Incident City',
                                [validators.Length(min=1, max=100)])
    incident_state = StringField('Incident City',
                                 [validators.Length(min=1, max=100)])
    incident_zipcode = IntegerField('Incident Number', [validators.required()])
    incident_county = StringField('Incident County',
                                  [validators.Length(min=1, max=30)])
    incident_location_type = StringField("Incident Location Type",
                                         [validators.Length(min=1, max=100)])
    disposition = SelectField(
        'Activity Category Type',
        validators=[DataRequired()],
        choices=[('Treated Transport EMS', 'Treated Transport EMS'),
                 ('Cancelled', 'Cancelled'),
                 ('Treated and Released', 'Treated and Released'),
                 ('No Patient Found', 'No Patient Found'),
                 ('No Treatment Required', 'No Treatment Required'),
                 ('Dead at Scene', 'Dead at Scene')])
    patient_name = StringField('Incident Address',
                               [validators.Length(min=1, max=100)])
Exemple #10
0
class UploadForm(FlaskForm):
    """File upload and shapefile selection form"""

    upload = FileField('Choose Your CSV File',
                       validators=[
                           FileRequired(),
                           FileAllowed(['csv'],
                                       'Invalid File Type. Must be .csv')
                       ])
    projection = RadioField('What Projection is Your Data In?',
                            validators=[DataRequired()],
                            choices=[('wgs', 'Geographic'),
                                     ('stateplane', 'Long Island State Plane')
                                     ])
    selection = MultiCheckboxField('Geographies to Join On',
                                   validators=[DataRequired()],
                                   coerce=int)
    submit = SubmitField("Process")
Exemple #11
0
class SearchForm(FlaskForm):
    q = StringField('Search...', validators=[DataRequired()])

    def __init__(self, *args, **kwargs):
        if 'formdata' not in kwargs:
            kwargs['formdata'] = request.args
        if 'csrf_enabled' not in kwargs:
            kwargs['csrf_enabled'] = False
        super(SearchForm, self).__init__(*args, **kwargs)
Exemple #12
0
class RequestResetForm(FlaskForm):
    email = StringField('Email', validators=[DataRequired(), Email()])
    submit = SubmitField('Request Password Reset')

    def validate_email(self, email):
        agent = Agent.query.filter_by(email=email.data).first()
        if agent is None:
            raise ValidationError(
                'There is no account with that email. You must register first.'
            )
Exemple #13
0
class CreateForm(FlaskForm):
    name = TextField("Name", validators=[DataRequired()])
    description = TextAreaField("Description", validators=[DataRequired()])
    image = FileField('Image', validators=[FileRequired()])
    banner = FileField('Image', validators=[FileRequired()])
    youtubeVideoURL = TextField("Trailer on Youtube",
                                validators=[DataRequired()])

    category = SelectField('Genre',
                           choices=[('1', 'Action'), ('2', 'Action-Adventure'),
                                    ('3', 'Adventure'), ('4', 'Role-playing'),
                                    ('5', 'Simulation'), ('6', 'Sports'),
                                    ('7', 'Strategy')])

    platform = SelectField('Platform',
                           choices=[('Playstation', 'Playstation'),
                                    ('XBox', 'XBox'), ('PC', 'PC')])

    creators = TextField('Creators', validators=[DataRequired()])

    release_date = DateField('Release Date', format='%m/%d/%Y')

    submit = SubmitField("Create")
Exemple #14
0
class RegForm(FlaskForm):
    agent_first_name = StringField(validators=[DataRequired()])
    agent_last_name = StringField(validators=[DataRequired()])
    country = SelectField()

    agent_password = PasswordField(validators=[DataRequired()])
    confirm_password = PasswordField('Confirm password',
                                     validators=[
                                         DataRequired(),
                                         EqualTo(
                                             'password',
                                             message='Passwords must match')
                                     ])

    agent_email = StringField(validators=[DataRequired()])
    agent_phone_no = StringField(validators=[DataRequired()])
    gender = SelectField(choices=[('male', "Male"), ("female", "Female")],
                         validators=[DataRequired()])
    agent_photo = FileField(
        'Upload', validators=[FileAllowed(['jpg', 'png']),
                              DataRequired()])
    submit = SubmitField('Register')
Exemple #15
0
class LoginForm(FlaskForm):
    username = StringField("Username", validators=[DataRequired()])
    password = PasswordField("Password", validators=[DataRequired()])
Exemple #16
0
class LoginForm(FlaskForm):
    username = StringField('用户名', validators=[DataRequired()])
    password = PasswordField('密码', validators=[DataRequired(), Length(1, 128)])
    remember = BooleanField('Remember me')
    submit = SubmitField('登录')
Exemple #17
0
class ResetPasswordForm(FlaskForm):
    password = PasswordField('Password', validators=[DataRequired()])
    confirm_password = PasswordField(
        'Confirm Password', validators=[DataRequired(),
                                        EqualTo('password')])
    submit = SubmitField('Reset Password')
Exemple #18
0
class LoginForm(FlaskForm):
    agent_email = StringField(validators=[DataRequired()])
    agent_password = PasswordField(validators=[DataRequired()])
    remember = BooleanField('Remember Me')
    submit = SubmitField('Sign In')
Exemple #19
0
class ReviewForm(FlaskForm):
    name = StringField(validators=[DataRequired()])
    message = TextAreaField(validators=[DataRequired()])
    email = StringField(validators=[DataRequired()])
    submit = SubmitField('Post review')
Exemple #20
0
class UploadForm(FlaskForm):
    file = FileField('File:', render_kw={"class": "form-control btn btn-outline-info"}, validators=[
        FileRequired(),
        FileAllowed(['bz2', '7z', 'tar', 'gz', 'zip', 'sdf', 'txt', 'smi', 'csv', 'tsv', 'xlsx'],
                    'Please upload only allowed files! (.txt, .)')
    ])
    catalog_type = SelectField('Catalog Type:', render_kw={"class": "form-control m-input"}, validators=[DataRequired()],
                       choices=[('', '--- Select one ---'), ('bb', 'Building Blocks'), ('sc', 'Screening Compounds'), ('both', 'Mixed'),
                                ('np', 'Natural Products'), ('bio', 'Bioactives'), ]
    )
    availability = SelectField('Availability:',
                                 render_kw={"class": "form-control m-input"}, validators=[DataRequired()],
                                 choices=[('', '--- Select one ---'), ('stock', 'In Stock'), ('demand', 'Make on Demand')]
    )
    upload_type = SelectField('Upload Type:', render_kw={"class": "form-control m-input"}, validators=[DataRequired()],
                              choices=[('', '--- Select one ---'), ('full', 'Full Catalog Update'), ('incremental', 'Incremental Catalog Update')]
                              )
    # natural_products = BooleanField(' Natural products')
    submit = SubmitField('Submit', render_kw={"class": "btn btn-primary"})
Exemple #21
0
class VideoForm(FlaskForm):
    description = TextAreaField('description', validators=[DataRequired()])
    url = TextAreaField('url', validators=[DataRequired()])
    submit = SubmitField('submit')
Exemple #22
0
class EditVideoForm(FlaskForm):
    description = TextAreaField('description', validators=[DataRequired()])
    url = TextAreaField('url', validators=[DataRequired()])
    submit = SubmitField('update')
    delete = SubmitField('delete')
Exemple #23
0
class ApartmentForm(FlaskForm):
    apartment_name = StringField(validators=[DataRequired()])
    description = TextAreaField(validators=[DataRequired()])
    country = StringField(validators=[DataRequired()])
    city = StringField(validators=[DataRequired()])
    neighborhood = StringField(validators=[DataRequired()])
    location = StringField(validators=[DataRequired()])
    postal_code = StringField(validators=[DataRequired()])
    property_status = SelectField(choices=[('for sale', "For Sale"),
                                           ("for rent", "For Rent")],
                                  validators=[DataRequired()])
    property_type = SelectField(choices=[("apartment", 'Apartment'),
                                         ("house", "House"),
                                         ("office", "Office"),
                                         ("condo", "Condominium"),
                                         ("store", "Store")],
                                validators=[DataRequired()])
    year_built = DateField(validators=[DataRequired()])
    video_data = FileField('Video tour guide',
                           validators=[FileAllowed(['mp4', 'webm', 'hd'])])
    photo = FileField('',
                      validators=[FileAllowed(['jpg', 'png']),
                                  DataRequired()])
    photo1 = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    photo2 = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    photo3 = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    photo4 = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    photo5 = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    photo6 = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    photo7 = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    photo8 = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    photo9 = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    photo0 = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    front_plan = FileField(
        '', validators=[FileAllowed(['jpg', 'png']),
                        DataRequired()])
    no_of_bedrooms = IntegerField(validators=[DataRequired()])
    no_of_bathrooms = IntegerField(validators=[DataRequired()])
    no_of_garages = IntegerField(validators=[DataRequired()])
    property_id = IntegerField(validators=[DataRequired()])
    area_size = IntegerField(validators=[DataRequired()])
    price = IntegerField(validators=[DataRequired()])
    second_price = IntegerField(validators=[DataRequired()])
    price_label = SelectField(choices=[("full sale", "Sale"),
                                       ('month', "Monthly"),
                                       ("year", "Yearly")],
                              validators=[DataRequired()])
    air_conditioning = BooleanField('air_conditioning')
    laundry = BooleanField('laundry')
    refrigerator = BooleanField('refrigerator')
    washer = BooleanField('washer')
    balcony = BooleanField('balcony')
    lawn = BooleanField('lawn')
    sauna = BooleanField('sauna')
    wifi = BooleanField('wifi')
    dryer = BooleanField('dryer')
    fireplace = BooleanField('fireplace')
    swimming_pool = BooleanField('swimming_pool')
    window_coverings = BooleanField('window_coverings')
    gym = BooleanField('gym')
    outdoor_shower = BooleanField('outdoor_shower')
    tv_cable = BooleanField('tv_cable')
    microwave = BooleanField('microwave')
    submit = SubmitField('Submit Property')
Exemple #24
0
class WriteQuestionForm(FlaskForm):
    img = FileField(
        label='上传图片',
        render_kw={"accept": ".jpeg, .jpg, .png"},
        validators=[FileAllowed(['jpg', 'png', 'jpeg'], '请选择合适的图片类型')])

    title = StringField(label='标题',
                        render_kw={
                            'class': "form-control",
                            'placeholder': '请输入标题(最多50个字)'
                        },
                        validators=[
                            DataRequired('请输入标题'),
                            Length(min=2, max=50, message='标题长度2-50')
                        ])

    tags = StringField(label='标签',
                       render_kw={
                           'class': "form-control",
                           'placeholder': '输入标签,用,分隔'
                       },
                       validators=[])

    desc = TextAreaField(label='描述',
                         render_kw={
                             'class': "form-control",
                             'placeholder': '简述'
                         },
                         validators=[])

    content = CKEditorField(
        label='文章内容',
        render_kw={
            'class': "form-control",
            'placeholder': '请输入正文',
        },
        validators=[DataRequired('请输入正文'),
                    Length(min=5, message='标题长度2-50')])

    def save(self):
        title = self.title.data
        desc = self.desc.data
        content = self.content.data
        img = self.img.data
        img_name = ''
        if img:
            print('img:', img)
            img_name = secure_filename(img.filename)
            img_path = os.path.join(current_app.config['MEDIA_ROOT'], img_name)
            img.save(img_path)
        que_obj = Question(title=title,
                           desc=desc,
                           img=img_name,
                           content=content,
                           user=current_user)
        db.session.add(que_obj)
        tags = self.tags.data
        for tag in tags.split(','):
            if tag:
                tag_obj = QuestionTags(tag_name=tag, question=que_obj)
                db.session.add(tag_obj)
        db.session.commit()

        return que_obj