Esempio n. 1
0
 def test_checkbox_input(self, basic_widget_dummy_field):
     assert (CheckboxInput()(basic_widget_dummy_field, value="v") ==
             '<input checked id="id" name="bar" type="checkbox" value="v">')
     # set falsy value to dummy field
     setattr(basic_widget_dummy_field, "data", "")
     assert "checked" not in CheckboxInput()(basic_widget_dummy_field)
     setattr(basic_widget_dummy_field, "data", False)
     assert "checked" not in CheckboxInput()(basic_widget_dummy_field)
Esempio n. 2
0
 def test_checkbox_input(self, basic_widget_dummy_field):
     assert (CheckboxInput()(basic_widget_dummy_field, value="v") ==
             '<input checked id="id" name="bar" type="checkbox" value="v">')
     # set falsy value to dummy field
     basic_widget_dummy_field.data = ""
     assert "checked" not in CheckboxInput()(basic_widget_dummy_field)
     basic_widget_dummy_field.data = False
     assert "checked" not in CheckboxInput()(basic_widget_dummy_field)
Esempio n. 3
0
class MultiCheckboxField(SelectMultipleField):

    widget = ListWidget(prefix_label=False)
    option_widget = CheckboxInput()

    def pre_validate(self, form):
        pass
Esempio n. 4
0
class MultiCheckboxField(SelectMultipleField):
    widget = CheckboxListWidget()
    option_widget = CheckboxInput()
Esempio n. 5
0
class IndicoSelectMultipleCheckboxField(SelectMultipleField):
    widget = JinjaWidget('forms/checkbox_group_widget.html',
                         single_kwargs=True)
    option_widget = CheckboxInput()
Esempio n. 6
0
class IndicoQuerySelectMultipleCheckboxField(IndicoQuerySelectMultipleField):
    option_widget = CheckboxInput()
Esempio n. 7
0
class VenueForm(Form):
    name = StringField('name', validators=[DataRequired()])
    city = StringField('city', validators=[DataRequired()])
    state = SelectField('state',
                        validators=[DataRequired()],
                        choices=[
                            ('AL', 'AL'),
                            ('AK', 'AK'),
                            ('AZ', 'AZ'),
                            ('AR', 'AR'),
                            ('CA', 'CA'),
                            ('CO', 'CO'),
                            ('CT', 'CT'),
                            ('DE', 'DE'),
                            ('DC', 'DC'),
                            ('FL', 'FL'),
                            ('GA', 'GA'),
                            ('HI', 'HI'),
                            ('ID', 'ID'),
                            ('IL', 'IL'),
                            ('IN', 'IN'),
                            ('IA', 'IA'),
                            ('KS', 'KS'),
                            ('KY', 'KY'),
                            ('LA', 'LA'),
                            ('ME', 'ME'),
                            ('MT', 'MT'),
                            ('NE', 'NE'),
                            ('NV', 'NV'),
                            ('NH', 'NH'),
                            ('NJ', 'NJ'),
                            ('NM', 'NM'),
                            ('NY', 'NY'),
                            ('NC', 'NC'),
                            ('ND', 'ND'),
                            ('OH', 'OH'),
                            ('OK', 'OK'),
                            ('OR', 'OR'),
                            ('MD', 'MD'),
                            ('MA', 'MA'),
                            ('MI', 'MI'),
                            ('MN', 'MN'),
                            ('MS', 'MS'),
                            ('MO', 'MO'),
                            ('PA', 'PA'),
                            ('RI', 'RI'),
                            ('SC', 'SC'),
                            ('SD', 'SD'),
                            ('TN', 'TN'),
                            ('TX', 'TX'),
                            ('UT', 'UT'),
                            ('VT', 'VT'),
                            ('VA', 'VA'),
                            ('WA', 'WA'),
                            ('WV', 'WV'),
                            ('WI', 'WI'),
                            ('WY', 'WY'),
                        ])
    address = StringField('address', validators=[DataRequired()])
    phone = StringField('phone')

    def validate_phone(form, field):
        value = field.data
        print(value)

        if not re.search("^[0-9-]*$", value):
            msg = u"Invalid phone number."
            raise ValidationError(msg)

    image_link = StringField('image_link')
    genres = SelectMultipleField('genres',
                                 validators=[DataRequired()],
                                 choices=[
                                     ('Alternative', 'Alternative'),
                                     ('Blues', 'Blues'),
                                     ('Classical', 'Classical'),
                                     ('Country', 'Country'),
                                     ('Electronic', 'Electronic'),
                                     ('Folk', 'Folk'),
                                     ('Funk', 'Funk'),
                                     ('Hip-Hop', 'Hip-Hop'),
                                     ('Heavy Metal', 'Heavy Metal'),
                                     ('Instrumental', 'Instrumental'),
                                     ('Jazz', 'Jazz'),
                                     ('Musical Theatre', 'Musical Theatre'),
                                     ('Pop', 'Pop'),
                                     ('Punk', 'Punk'),
                                     ('R&B', 'R&B'),
                                     ('Reggae', 'Reggae'),
                                     ('Rock n Roll', 'Rock n Roll'),
                                     ('Soul', 'Soul'),
                                     ('Other', 'Other'),
                                 ])
    facebook_link = StringField('facebook_link', validators=[URL()])
    website = StringField('website', validators=[URL()])
    image_link = StringField('image_link', validators=[URL()])
    seeking_talent = StringField('seeking_talent', widget=CheckboxInput())
    seeking_description = StringField('seeking_description', widget=TextArea())