class CollectionCreateForm(FlaskForm): name = StringField('Collection Name', validators=[Required()]) gif_picks = SelectMultipleField('GIFs to include') submit = SubmitField("Create Collection")
class EmpresaForm(FlaskForm): nombre_empresa = StringField('Nombre de la Empresa', validators=[DataRequired()]) l_examenes = MultiCheckboxField('Examenes', validators=[DataRequired()]) l_paquetes = SelectMultipleField('Paquetes', validators=[DataRequired()]) submit = SubmitField('Agregar Empresa')
class ArtistForm(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"), ], ) phone = StringField( # TODO implement validation logic for state # I dont know how to do? # Could you please help? "phone" ) image_link = StringField("image_link") genres = SelectMultipleField( # DONE implement enum restriction "genres", validators=[DataRequired()], choices=[(genre, genre.name) for genre in MusicGenre], ) facebook_link = StringField( # TODO implement enum restriction # I dont know how to do? # Could you please help? "facebook_link", validators=[URL()], ) seeking_venue = RadioField( "seeking_venue", validators=[DataRequired()], choices=[(True, "Yes"), (False, "No")], ) seeking_description = StringField( "seeking_description", )
def generate_settings_form(settings): # noqa: C901 """Generates a settings form which includes field validation based on our Setting Schema.""" class SettingsForm(FlaskPetForm): pass # now parse the settings in this group for setting in settings: field_validators = [] if setting.value_type in { SettingValueType.integer, SettingValueType.float }: validator_class = validators.NumberRange elif setting.value_type == SettingValueType.string: validator_class = validators.Length # generate the validators if "min" in setting.extra: # Min number validator field_validators.append(validator_class(min=setting.extra["min"])) if "max" in setting.extra: # Max number validator field_validators.append(validator_class(max=setting.extra["max"])) # Generate the fields based on value_type # IntegerField if setting.value_type == SettingValueType.integer: setattr( SettingsForm, setting.key, IntegerField(setting.name, validators=field_validators, description=setting.description)) # FloatField elif setting.value_type == SettingValueType.float: setattr( SettingsForm, setting.key, FloatField(setting.name, validators=field_validators, description=setting.description)) # TextField elif setting.value_type == SettingValueType.string: setattr( SettingsForm, setting.key, TextField(setting.name, validators=field_validators, description=setting.description)) # SelectMultipleField elif setting.value_type == SettingValueType.selectmultiple: # if no coerce is found, it will fallback to unicode if "coerce" in setting.extra: coerce_to = setting.extra['coerce'] else: coerce_to = text_type setattr( SettingsForm, setting.key, SelectMultipleField(setting.name, choices=setting.extra['choices'](), coerce=coerce_to, description=setting.description)) # SelectField elif setting.value_type == SettingValueType.select: # if no coerce is found, it will fallback to unicode if "coerce" in setting.extra: coerce_to = setting.extra['coerce'] else: coerce_to = text_type setattr( SettingsForm, setting.key, SelectField(setting.name, coerce=coerce_to, choices=setting.extra['choices'](), description=setting.description)) # BooleanField elif setting.value_type == SettingValueType.boolean: setattr( SettingsForm, setting.key, BooleanField(setting.name, description=setting.description)) return SettingsForm
class DataBase(FlaskForm): reorder_type = StringField('Reorder Type', widget=widgets.HiddenInput()) list_visible_elements = SelectMultipleField('New Order') reorder = SubmitField(TRANSLATIONS['save_order']['title'])
class ReportForm(Form): report_id = HiddenField("") schedule_timezone = HiddenField("") report_title = StringField( ("Title"), description="Title will be used as the report's name", widget=BS3TextFieldWidget(), validators=[DataRequired()], ) description = TextAreaField( ("Description"), widget=BS3TextAreaFieldWidget(), validators=[DataRequired()], ) owner_name = StringField( ("Owner Name"), # widget=BS3TextFieldWidget(), validators=[DataRequired()], ) owner_email = StringField( ("Owner Email"), description="Owner email will be added to the subscribers list", # widget=BS3TextFieldWidget(), validators=[DataRequired(), Email()], ) subscribers = StringField( ("Subscribers"), description=( "List of comma separeted emails that should receive email\ notifications. Automatically adds owner email to this list." ), ) tests = SelectMultipleField( ("Tests"), description=( "List of the tests to include in the report. Only includes\ tasks that have ran in airflow."), choices=None, widget=Select2ManyWidget(style="width:50%"), validators=[DataRequired()], ) schedule_type = SelectField( ("Schedule"), description=("Select how you want to schedule the report"), choices=[ ("manual", "None (Manual triggering)"), ("daily", "Daily"), ("weekly", "Weekly"), ("custom", "Custom (Cron)"), ], widget=Select2Widget(), validators=[DataRequired()], ) schedule_time = TimeField("Time", render_kw={"class": "form-control"}, validators=[Optional()]) schedule_week_day = SelectField( ("Day of week"), description=( "Select day of a week you want to schedule the report"), choices=[ ("0", "Sunday"), ("1", "Monday"), ("2", "Tuesday"), ("3", "Wednesday"), ("4", "Thursday"), ("5", "Friday"), ("6", "Saturday"), ], widget=Select2Widget(), validators=[DataRequired()], ) schedule_custom = StringField( ("Cron schedule"), description='Enter cron schedule (e.g. "0 0 * * *")', # widget=BS3TextFieldWidget(), # validators=[DataRequired()], )
class SaveFavoriteForm(FlaskForm): name = StringField('Collection Name', validators=[Required()]) favorite_articles = SelectMultipleField('Articles to save') submit = SubmitField("Save")
class RegistrationStudentForm(RegistrationForm): last_name = StringField(prefix_field_required + 'фамилия', validators=[Length(1, 60)]) first_name = StringField(prefix_field_required + 'имя', validators=[Length(1, 60)]) second_name = StringField('отчество', validators=[Length(0, 60)]) birth_date = DateFieldWidget(prefix_field_required + 'дата рождения', validators=[DataRequired()]) birth_place = StringField(prefix_field_required + 'место рождения', validators=[Length(1, 255)]) registration_place = StringField(prefix_field_required + 'адрес регистрации', validators=[Length(1, 255)]) actual_address = StringField(prefix_field_required + 'фактический адрес проживания', validators=[Length(1, 255)]) additional_info = TextAreaField('дополнительная информация', validators=[Length(0, 255)]) known_from = StringField('откуда узнал(а) о ЦМИТ', validators=[Length(0, 255)]) citizenship = SelectField(prefix_field_required + 'гражданство', coerce=int, validators=[DataRequired()]) school = SelectField(prefix_field_required + 'школа', coerce=int, validators=[DataRequired()]) grade = StringField(prefix_field_required + 'класс', validators=[Length(1, 31)]) shift = StringField(prefix_field_required + 'смена', validators=[Length(1, 31)]) phone = StringField('телефон', validators=[Phone(allow_empty=True)]) contact_phone = SelectField(prefix_field_required + 'телефон для связи', coerce=int, validators=[DataRequired()]) mother_search = StringField('мать. поиск', validators=[Optional()]) mother = SelectField('мать (при создании нового заполните поля ниже)', coerce=int, validators=[Optional()]) father_search = StringField('отец. поиск', validators=[Optional()]) father = SelectField('отец (при создании нового заполните поля ниже)', coerce=int, validators=[Optional()]) m_fio = StringField(prefix_field_required + 'новая мать: фио', validators=[Length(0, 255)]) m_phone = StringField(prefix_field_required + 'новая мать: телефон', validators=[Phone(allow_empty=True)]) m_email = StringField('новая мать: email', validators=[Optional(), Length(0, 128), Email()]) m_passport = StringField('новая мать: паспорт', validators=[Optional(), Length(0, 255)]) m_address = StringField('новая мать: адрес', validators=[Optional(), Length(0, 255)]) m_home_phone = StringField('новая мать: домашний телефон', validators=[Length(0, 32)]) m_vk_link = StringField('новая мать: ВКонтакте', validators=[Optional(), Length(0, 64), VkLink()]) m_notification_types = SelectMultipleField('новая мать: уведомления', coerce=int, validators=[Optional()]) f_fio = StringField(prefix_field_required + 'новый отец: фио', validators=[Length(0, 255)]) f_phone = StringField(prefix_field_required + 'новый отец: телефон', validators=[Phone(allow_empty=True)]) f_email = StringField('новый отец: email', validators=[Optional(), Length(0, 128), Email()]) f_passport = StringField('новый отец: паспорт', validators=[Optional(), Length(0, 255)]) f_address = StringField('новый отец: адрес', validators=[Optional(), Length(0, 255)]) f_home_phone = StringField('новый отец: домашний телефон', validators=[Length(0, 32)]) f_vk_link = StringField('новый отец: ВКонтакте', validators=[Optional(), Length(0, 64), VkLink()]) f_notification_types = SelectMultipleField('новый отец: уведомления', coerce=int, validators=[Optional()]) def required_fields_values_new_mother(self): return [self.m_fio.data, self.m_phone.data] def required_fields_values_new_father(self): return [self.f_fio.data, self.f_phone.data] submit = SubmitField('создать ученика') def __init__(self, student=None, *args, **kwargs): super(RegistrationStudentForm, self).__init__(*args, *kwargs) schools = [(school.id, school.name) for school in School.query.order_by(School.name).all()] if student is None: schools = [(-1, 'выберите школу')] + schools self.school.choices = schools self.contact_phone.choices = contact_phone_variants self.citizenship.choices = [ (c.id, c.name) for c in Citizenship.query.order_by(Citizenship.id).all() ] parents = [(p.id, p.fio) for p in Parent.query.order_by(Parent.fio).all()] parents = [(create_new_parent_id, 'создать нового')] + parents parents = [(no_parent_id, 'нет')] + parents self.mother.choices = parents self.father.choices = parents self.m_notification_types.choices = [[no_parent_id, 'нет'] ] + notification_types_list self.f_notification_types.choices = [[no_parent_id, 'нет'] ] + notification_types_list self.student = student if student is not None: del self.last_name del self.first_name del self.second_name self.setup_for_editing() self.system_user = student.system_user else: # this fields are generated from last_name / first_name / second_name. del self.login del self.fio del self.password del self.password_confirm def validate_school(self, field): if field.data <= 0: raise ValidationError('школа не выбрана!') def validate_contact_phone(self, field): if field.data == contact_phone_student and self.phone.data == '': raise ValidationError('укажите телефон ученика!') if field.data == contact_phone_mother and self.mother.data == no_parent_id: raise ValidationError('мать не указана!') if field.data == contact_phone_father and self.father.data == no_parent_id: raise ValidationError('отец не указан!') def validate_father(self, field): if field.data > 0 and field.data == self.mother.data: raise ValidationError('отец не может быть матерью!') if field.data == create_new_parent_id: if any( len(p) == 0 for p in self.required_fields_values_new_father()): raise ValidationError( 'заполните поля в "новый родитель - отец"!') # if self.f_passport.data is empty, nothing will be found because empty passport is stored in DB as NULL. if Parent.query.filter_by(_passport=self.f_passport.data).first(): raise ValidationError('паспорт отца уже зарегистрирован!') if self.mother.data == create_new_parent_id and self.f_passport.data.strip() != '' \ and self.f_passport.data == self.m_passport.data: raise ValidationError('паспорта родителей совпадают!') def validate_mother(self, field): if field.data == create_new_parent_id: if any( len(p) == 0 for p in self.required_fields_values_new_mother()): raise ValidationError( 'заполните поля в "новый родитель - мать"!') if Parent.query.filter_by(_passport=self.m_passport.data).first(): raise ValidationError('паспорт матери уже зарегистрирован!') def validate_m_notification_types(self, field): if self.mother.data != create_new_parent_id: return ni_ints = notification_types_list_to_int(field.data) if ni_ints & (1 << shift_email) != 0 and self.m_email.data.strip( ) == '': raise ValidationError('укажите email!') if ni_ints & (1 << shift_vk) != 0 and self.m_vk_link.data.strip( ) == '': raise ValidationError('укажите ВКонтакте!') # don't check phone here because it is required. def validate_f_notification_types(self, field): if self.father.data != create_new_parent_id: return ni_ints = notification_types_list_to_int(field.data) if ni_ints & (1 << shift_email) != 0 and self.f_email.data.strip( ) == '': raise ValidationError('укажите email!') if ni_ints & (1 << shift_vk) != 0 and self.f_vk_link.data.strip( ) == '': raise ValidationError('укажите ВКонтакте!')
class PlaylistCreateForm(FlaskForm): name = StringField('Playlist Name', validators=[Required()]) song_picks = SelectMultipleField('Songs to include') submit = SubmitField("Create Playlist")
class OlympicMedals(FlaskForm): NOC = SelectMultipleField('Select Multiple:' , validators = [DataRequired] ) StartYear = StringField('Start Year:' , validators = [DataRequired]) EndYear = StringField('End Year:' , validators = [DataRequired]) KindofGraph = SelectField('Chart Kind' , validators = [DataRequired] , choices=[('barh', 'barh'), ('bar', 'bar'), ('line', 'line')]) submit = SubmitField('submit')
class ArtistForm(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'), ]) phone = StringField( # TODO implement validation logic for state 'phone') image_link = StringField('image_link', validators=[URL()]) genres = SelectMultipleField( # TODO implement enum restriction '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'), ]) seeking_venue = BooleanField('seeking_venue', default='checked') seeking_description = TextAreaField( 'seeking_description', default='We need a venue to play for upcoming weekends.', validators=[ Optional(), Length(min=10, message='Description is too short.') ]) facebook_link = StringField( # TODO implement enum restriction 'facebook_link', validators=[URL()]) website_link = StringField('website_link', validators=[URL()])
class SearchForm(FlaskForm): title = StringField('Title') tags = SelectMultipleField('Tags') date_posted = DateField('Date_posted') submit = SubmitField('Search')
class CollectionCreateForm(FlaskForm): name = StringField('Collection Name', validators=[Required()]) photo_picks = SelectMultipleField( 'Select photos based on the number of likes to give you a unique collection!' ) submit = SubmitField("Create Collection")
class DeleteMultiForm(Form): options = SelectMultipleField(u"Filename", choices=[])
def __init__(self, maximum=5, **kwargs): SelectMultipleField.__init__(self, **kwargs) self.maximum = maximum
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") image_link = StringField("image_link") genres = SelectMultipleField( # TODO implement enum restriction "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()])
class StudentPersonalQs(FlaskForm): Gender = RadioField('Gender', choices=[('Male', 'Male'), ('Female', 'Female')]) Age = SelectField('Age', choices=[('12', '12'), ('13', '14'), ('15', '15'), ('16', '16'), ('17', '17'), ('18+', '18+')]) Year = SelectField('Year', choices=[('1st year', '1st year'), ('2nd year', '2nd year'), ('3rd year', '3rd year'), ('4th year', '4th year'), ('5th year', '5th year'), ('6th year', '6th year')]) NativeEnglishSpeaker = RadioField( 'NativeEnglishSpeaker', validators=[InputRequired('Fix this please12111')], choices=[('Yes', 'Yes'), ('No', 'No')]) MorningOrNight = RadioField('MorningOrNight', choices=[('Morning', 'Morning'), ('Night', 'Night'), ('No preference', 'No preference')]) OwnSmartPhone = RadioField('OwnSmartPhone', choices=[('Yes', 'Yes'), ('No', 'No')]) HaveSphoneAccess = StringField('HaveSphoneAccess') PhoneHours = SelectField('PhoneHours', choices=[('Less than 1 hour', 'Less than 1 hour'), ('1-3 hours', '1-3 hours'), ('More than 3 hours', 'More than 3 hours'), ('None', 'None')]) PhoneActivity = SelectMultipleField( 'PhoneActivity', choices= [('Texting (SMS)', 'Texting (SMS)'), ('Calling (using the phones network)', 'Calling (using the phones network)'), ('Other forms of messaging (Facebook Messenger, Whatsapp, Viber etc.)', 'Other forms of messaging (Facebook Messenger, Whatsapp, Viber etc.)' ), ('Facebook', 'Facebook'), ('Snapchat', 'Snapchat'), ('Instagram', 'Instagram'), ('Browsing the web (using Safari/Chrome etc.)', 'Browsing the web (using Safari/Chrome etc.)'), ('Playing games', 'Playing games'), ('Looking up news/information (BBC, RTE, Wikipedia etc.)', 'Looking up news/information (BBC, RTE, Wikipedia etc.)'), ('Taking photos', 'Taking photos'), ('Sending/reading emails', 'Sending/reading emails'), ('Reading books/newspapers etc.', 'Reading books/newspapers etc.'), ('Listen to music (ITunes, Spotify)', 'Listen to music (ITunes, Spotify)'), ('Watch videos (using Netflix, YouTube etc.)', 'Watch videos (using Netflix, YouTube etc.)'), ('Other', 'Other')]) OwnPersonalComputer = RadioField('OwnPersonalComputer', choices=[('Yes', 'Yes'), ('No', 'No')]) HaveComputerAccess = StringField('HaveComputerAccess') ComputerHours = SelectField('ComputerHours', choices=[ ('Less than 1 hour', 'Less than 1 hour'), ('1-3 hours', '1-3 hours'), ('More than 3 hours', 'More than 3 hours'), ('None', 'None') ]) ComputerActivity = SelectMultipleField( 'ComputerActivity', choices=[('Instagram', 'Instagram'), ('Browsing the web (using Safari/Chrome etc.)', 'Browsing the web (using Safari/Chrome etc.)'), ('Facebook & other social media', 'Facebook & other social media'), ('Playing games', 'Playing games'), ('Looking up news/information (BBC, RTE, Wikipedia etc.)', 'Looking up news/information (BBC, RTE, Wikipedia etc.)'), ('Sending/reading emails', 'Sending/reading emails'), ('School work or similar (using Word, Powerpoint etc.)', 'School work or similar (using Word, Powerpoint etc.)'), ('Watch videos (using Netflix, YouTube etc.)', 'Watch videos (using Netflix, YouTube etc.)'), ('Listening to music', 'Listening to music'), ('Other', 'Other')]) OwnTablet = RadioField('OwnTablet', choices=[('Yes', 'Yes'), ('No', 'No')]) TabletHours = SelectField('TabletHours', choices=[ ('Less than 1 hour', 'Less than 1 hour'), ('1-3 hours', '1-3 hours'), ('More than 3 hours', 'More than 3 hours'), ('None', 'None') ]) TabletActivity = SelectMultipleField( 'TabletActivity', choices= [('Instagram', 'Instagram'), ('Browsing the web (using Safari/Chrome etc.)', 'Browsing the web (using Safari/Chrome etc.)'), ('Facebook', 'Facebook'), ('Playing games', 'Playing games'), ('Looking up news/information (BBC, RTE, Wikipedia etc.)', 'Looking up news/information (BBC, RTE, Wikipedia etc.)'), ('Sending/reading emails', 'Sending/reading emails'), ('Snapchat', 'Snapchat'), ('Reading books/newspapers etc.', 'Reading books/newspapers etc.'), ('Some form of texting/messaging (Facebook Messenger, Whatsapp, Viber etc.)', 'Some form of texting/messaging (Facebook Messenger, Whatsapp, Viber etc.)' ), ('Listening to music', 'Listening to music'), ('Watch videos (using Netflix, YouTube etc.)', 'Watch videos (using Netflix, YouTube etc.)'), ('Other', 'Other')]) ProgrammingExperience = RadioField('ProgrammingExperience', choices=[('Yes', 'Yes'), ('No', 'No')]) ProgrammingExperienceTime = SelectField( 'ProgrammingExperienceTime', choices=[('I have never programmed before', 'I have never programmed before'), ('I have programmed once or twice', 'I have programmed once or twice'), ('I have done programming a number of times', 'I have done programming a number of times'), ('I have been programming for over a year', 'I have been programming for over a year')]) ProgrammingLanguages = SelectMultipleField('ProgrammingLanguages', choices=[('Java', 'Java'), ('Python', 'Python'), ('Scratch', 'Scratch'), ('C/C++', 'C/C++'), ('JavaScript', 'JavaScript'), ('Other', 'Other')]) ProgramOften = RadioField('ProgramOften', choices=[('Never', 'Never'), ('Barely', 'Barely'), ('Occassionly', 'Ocassionly'), ('Often', 'Often'), ('Daily', 'Daily')]) PersonalProgrammingProficiency = RadioField( 'PersonalProgrammingProficiency', choices=[('Bad', 'Bad'), ('Not the best', 'Not the best'), ('Average', 'Average'), ('Good', 'Good'), ('Excellent', 'Excellent')]) DoneWebOrAppDev = RadioField('DoneWebOrAppDev', choices=[('Yes', 'Yes'), ('No', 'No')]) KnownTechnologies = SelectMultipleField( 'KnownTechnologies ', choices=[('HTML', 'HTML'), ('CSS', 'CSS'), ('JavaScript', 'JavaScript'), ('PHP or other server-side langauge', 'PHP or other server-side langauge'), ('App Inventor', 'App Inventor'), ('Android Studio', 'Android Studio'), ('XCode (Apple App Development tool)', 'XCode (Apple App Development tool)')]) ProgrammingSites = SelectMultipleField( 'ProgrammingSites', choices=[('Bebras challenge', 'Bebras challenge'), ('Codecademy', 'Codecademy'), ('Khan Academy', 'Khan Academy'), ('Udacity', 'Udacity'), ('Kangaroo Maths', 'Kangaroo Maths'), ('Call to Code', 'Call to Code'), ('Hour of Code (code.org)', 'Hour of Code (code.org)'), ('AILO (All Ireland Linguistics Olympiad)', 'AILO (All Ireland Linguistics Olympiad)'), ('None of the above', 'None of the above'), ('Other', 'Other')]) JuniorCertLevel = RadioField('JuniorCertLevel', choices=[('Foundation', 'Foundation'), ('Ordinary ', 'Ordinary '), ('Higher', 'Higher')]) ITParentOccupation = RadioField('ITParentOccupation', choices=[('Yes', 'Yes'), ('No', 'No'), ('Not Sure', 'Not Sure')]) Submit = SubmitField('Submit')
class UserForm(FlaskForm): """Main form for User GUI""" name = StringField('User name', validators=[DataRequired()]) description = TextAreaField('Description', validators=[Optional()]) email = StringField('Email', validators=[Optional(), Email()]) # custom user fields user_info = FormField(UserInfoForm, "User info", _meta={'csrf': False}) password = PasswordField('Password') password2 = PasswordField('Repeat Password', validators=[EqualTo('password')]) totp_enabled = False totp_secret = StringField('TOTP secret', validators=[Optional(), Length(max=16)]) last_sign_in_at = StringField('Last sign in', validators=[Optional()]) failed_sign_in_count = IntegerField( 'Failed login attempts', widget=NumberInput(min=0), validators=[ Optional(), NumberRange(min=0, message="Number must be greater or equal 0") ]) groups = SelectMultipleField('Assigned groups', coerce=int, validators=[Optional()]) roles = SelectMultipleField('Assigned roles', coerce=int, validators=[Optional()]) submit = SubmitField('Save') def __init__(self, config_models, **kwargs): """Constructor :param ConfigModels config_models: Helper for ORM models """ self.config_models = config_models self.User = self.config_models.model('users') # store any provided user object self.obj = kwargs.get('obj') super(UserForm, self).__init__(**kwargs) def add_custom_fields(user_info_fields): """Add custom user_info fields. :param list(obj) user_info_fields: Custom user info fields """ for field in user_info_fields: field_class = StringField widget = None if field.get('type') == 'string': field_class = StringField if field.get('type') == 'textarea': field_class = TextAreaField elif field.get('type') == 'integer': field_class = IntegerField widget = NumberInput() validators = [Optional()] if field.get('required', False): validators = [DataRequired()] form_field = field_class(field['title'], widget=widget, validators=validators) # add custom field to UserInfoForm setattr(UserInfoForm, field['name'], form_field) def validate_name(self, field): # check if user name exists session = self.config_models.session() query = session.query(self.User).filter_by(name=field.data) if self.obj: # ignore current user query = query.filter(self.User.id != self.obj.id) user = query.first() session.close() if user is not None: raise ValidationError('Name has already been taken.') def validate_email(self, email): session = self.config_models.session() query = session.query(self.User).filter_by(email=email.data) if self.obj: # ignore current user query = query.filter(self.User.id != self.obj.id) user = query.first() session.close() if user is not None: raise ValidationError('Please use a different email address.')
class ListForm(FlaskForm): spells = SelectMultipleField('Spells', coerce=int) submit = SubmitField('Submit')
class NewEmailForm(FlaskForm): to = StringField(validators=[ DataRequired(i8n.EMAIL_TO_REQUIRED), Emails(AppConfig.EMAIL_ADDRESS_DELIMITER, i8n.EMAIL_ADDRESS_INVALID), ]) cc = StringField(validators=[ DataOptional(), Emails(AppConfig.EMAIL_ADDRESS_DELIMITER, i8n.EMAIL_ADDRESS_INVALID), ]) bcc = StringField(validators=[ DataOptional(), Emails(AppConfig.EMAIL_ADDRESS_DELIMITER, i8n.EMAIL_ADDRESS_INVALID), ]) subject = StringField(validators=[DataOptional()]) body = HtmlTextAreaField(validators=[ DataOptional(), ]) forwarded_attachments = SelectMultipleField(choices=[], validators=[ DataOptional(), ]) attachments = FileField(validators=[ DataOptional(), ], render_kw={ 'multiple': True, }) submit = SubmitField() def as_dict(self, email_store: EmailStore) -> dict: form = {key: value for (key, value) in self.data.items() if value} form.pop('submit', None) attachments = request.files.getlist(self.attachments.name) to = _split_emails(form.get('to')) cc = _split_emails(form.get('cc')) bcc = _split_emails(form.get('bcc')) sent_at = None if all(_is_local_message(address) for address in chain(to, cc, bcc)): sent_at = datetime.utcnow().strftime('%Y-%m-%d %H:%M') form['sent_at'] = sent_at form['read'] = True form['from'] = current_user.email form['to'] = to form['cc'] = cc form['bcc'] = bcc form['body'] = form.get('body') form['subject'] = form.get('subject', i8n.EMAIL_NO_SUBJECT) form['attachments'] = list(_attachments_as_dict(attachments)) return form def _populate(self, email_store: EmailStore): pass @classmethod def _new_instance_for(cls, action_name: Optional[str]): if not action_name: return cls(request.form) try: clazz = next(clazz for clazz in NewEmailForm.__subclasses__() if getattr(clazz, 'action_name', None) == action_name) except StopIteration: return None else: return clazz(request.form) def _get_reference_email(self, email_store: EmailStore) -> Optional[dict]: uid = request.args.get('uid', '') if not uid: return None reference = email_store.get(uid) if not current_user.can_access(reference): return None return reference @classmethod def from_request(cls, email_store: EmailStore): action_name = request.args.get('action') form = cls._new_instance_for(action_name) if not form: return None form._populate(email_store) return form
class VenueForm(Form): #wendy: validation code def validate_phone(form, field): if not re.search(r"^[0-9]{3}-[0-9]{3}-[0-9]{4}$", field.data): # if not re.search(r'^[0-9\-\+]+$', field.data): raise ValidationError("Invalid phone number.") def validate_genres(form, field): genres_values = [choice[1] for choice in genres_choices] for value in field.data: if value not in genres_values: raise ValidationError('Invalid genres value.') 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( #wendy 'phone',validators=[DataRequired(),validate_phone] ) image_link = StringField( 'image_link' ) genres = SelectMultipleField( # cTODO implement enum restriction #wendy 'genres', validators=[DataRequired(),validate_genres], choices=genres_choices ) facebook_link = StringField( 'facebook_link', validators=[URL()] )
class CreateMatrixForm(FlaskForm): categories = SelectMultipleField('Categories to compare', validators=[DataRequired()]) ratio = IntegerField('Training tweets proportion (%)', validators=[DataRequired()]) submit = SubmitField('Create Matrix')
class ArtistForm(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'), ]) phone = StringField( # TODO implement validation logic for state 'phone', validators=[InputRequired()]) image_link = StringField('image_link') genres = SelectMultipleField( # TODO implement enum restriction '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( # TODO implement enum restriction 'facebook_link', validators=[URL()]) def validate_phone(self, form, field): if len(field.data) > 16: raise ValidationError('Invalid phone number.') try: input_number = phonenumbers.parse(field.data) if not (phonenumbers.is_valid_number(input_number)): raise ValidationError('Invalid phone number.') except: input_number = phonenumbers.parse("+1" + field.data) if not (phonenumbers.is_valid_number(input_number)): raise ValidationError('Invalid phone number.')
def __init__(self, type, **kwargs): super(NotificationForm, self).__init__(**kwargs) if type == 'author': status_select = SelectField('Paper status', choices=[('Received', 'Received'), ('Accepted', 'Accepted'), ('Rejected', 'Rejected'), ('Under Review', 'Under Review')]) self.status_select = self._fields['status_select'] = \ self.meta.bind_field(self, status_select, {'name': 'status_select', 'prefix': self._prefix}) self.status_select.process_data('Received') paper_ids = MultipleCheckboxField('paper_ids', choices=[], coerce=int) self.paper_ids = self._fields['paper_ids'] = self.meta.bind_field( self, paper_ids, { 'name': 'paper_ids', 'prefix': self._prefix }) self.paper_ids.process_data(None) elif type == 'pc': email_receivers = SelectMultipleField('Receivers', choices=[], validators=[Required()]) self.email_receivers = self._fields['email_receivers'] = \ self.meta.bind_field(self, email_receivers, {'name': 'email_receivers', 'prefix': self._prefix}) self.email_receivers.process_data(None) receiver_type = RadioField( '', choices=[('checkbox_all', 'checkbox_all'), ('checkbox_missing', 'checkbox_missing'), ('checkbox_complete', 'checkbox_complete'), ('checkbox_other', 'checkbox_other')]) self.receiver_type = self._fields['receiver_type'] = \ self.meta.bind_field(self, receiver_type, {'name': 'receiver_type', 'prefix': self._prefix}) self.receiver_type.process_data('checkbox_all') elif type == 'member': email_receivers = SelectMultipleField('Receivers', choices=[], validators=[Required()]) self.email_receivers = self._fields['email_receivers'] = \ self.meta.bind_field(self, email_receivers, {'name': 'email_receivers', 'prefix': self._prefix}) elif type == 'session': email_receivers = SelectMultipleField('Receivers', choices=[], validators=[Required()]) self.email_receivers = self._fields['email_receivers'] = \ self.meta.bind_field(self, email_receivers, {'name': 'email_receivers', 'prefix': self._prefix}) receiver_type = RadioField( '', choices=[('checkbox_all', 'checkbox_all'), ('checkbox_speakers', 'checkbox_speakers'), ('checkbox_moderators', 'checkbox_moderators'), ('checkbox_discussants', 'checkbox_discussants')]) self.receiver_type = self._fields['receiver_type'] = \ self.meta.bind_field(self, receiver_type, {'name': 'receiver_type', 'prefix': self._prefix}) self.receiver_type.process_data('checkbox_all')
class InputMod(FlaskForm): input_id = StringField('Input ID', widget=widgets.HiddenInput()) input_measurement_id = StringField(widget=widgets.HiddenInput()) name = StringField( TRANSLATIONS['name']['title'], validators=[DataRequired()] ) period = DecimalField( TRANSLATIONS['period']['title'], validators=[DataRequired(), validators.NumberRange( min=5.0, max=86400.0 )], widget=NumberInput(step='any') ) start_offset = DecimalField( TRANSLATIONS['start_offset']['title'], validators=[DataRequired(), validators.NumberRange( min=0.0, max=86400.0 )], widget=NumberInput(step='any') ) log_level_debug = BooleanField( TRANSLATIONS['log_level_debug']['title']) num_channels = IntegerField(lazy_gettext('Number of Measurements'), widget=NumberInput()) location = StringField(lazy_gettext('Location')) ftdi_location = StringField(TRANSLATIONS['ftdi_location']['title']) uart_location = StringField(TRANSLATIONS['uart_location']['title']) gpio_location = IntegerField(TRANSLATIONS['gpio_location']['title']) i2c_location = StringField(TRANSLATIONS['i2c_location']['title']) i2c_bus = IntegerField(TRANSLATIONS['i2c_bus']['title'], widget=NumberInput()) baud_rate = IntegerField(TRANSLATIONS['baud_rate']['title'], widget=NumberInput()) power_output_id = StringField(lazy_gettext('Power Output')) # For powering input calibrate_sensor_measure = StringField(lazy_gettext('Calibration Measurement')) resolution = IntegerField(TRANSLATIONS['resolution']['title'], widget=NumberInput()) resolution_2 = IntegerField(TRANSLATIONS['resolution']['title'], widget=NumberInput()) sensitivity = IntegerField( TRANSLATIONS['sensitivity']['title'], widget=NumberInput()) measurements_enabled = SelectMultipleField(TRANSLATIONS['measurements_enabled']['title']) # Server options host = StringField(TRANSLATIONS['host']['title']) port = IntegerField( TRANSLATIONS['port']['title'], widget=NumberInput()) times_check = IntegerField( TRANSLATIONS['times_check']['title'], widget=NumberInput()) deadline = IntegerField( TRANSLATIONS['deadline']['title'], widget=NumberInput()) # Linux Command cmd_command = StringField(TRANSLATIONS['cmd_command']['title']) # MAX chip options thermocouple_type = StringField(TRANSLATIONS['thermocouple_type']['title']) ref_ohm = IntegerField( TRANSLATIONS['ref_ohm']['title'], widget=NumberInput()) # SPI Communication pin_clock = IntegerField( TRANSLATIONS['pin_clock']['title'], widget=NumberInput()) pin_cs = IntegerField( TRANSLATIONS['pin_cs']['title'], widget=NumberInput()) pin_mosi = IntegerField( TRANSLATIONS['pin_mosi']['title'], widget=NumberInput()) pin_miso = IntegerField( TRANSLATIONS['pin_miso']['title'], widget=NumberInput()) # Bluetooth Communication bt_adapter = StringField(lazy_gettext('BT Adapter (hci[X])')) # ADC adc_gain = IntegerField( TRANSLATIONS['adc_gain']['title'], widget=NumberInput()) adc_resolution = IntegerField( TRANSLATIONS['adc_resolution']['title'], widget=NumberInput()) adc_sample_speed = StringField(TRANSLATIONS['adc_sample_speed']['title']) switch_edge = StringField(lazy_gettext('Edge')) switch_bouncetime = IntegerField( lazy_gettext('Bounce Time (ms)'), widget=NumberInput()) switch_reset_period = IntegerField( lazy_gettext('Reset Period'), widget=NumberInput()) # Pre-Output pre_output_id = StringField(TRANSLATIONS['pre_output_id']['title']) pre_output_duration = DecimalField( TRANSLATIONS['pre_output_duration']['title'], validators=[validators.NumberRange( min=0, max=86400 )], widget=NumberInput(step='any') ) pre_output_during_measure = BooleanField( TRANSLATIONS['pre_output_during_measure']['title']) # RPM/Signal weighting = DecimalField( TRANSLATIONS['weighting']['title'], widget=NumberInput(step='any')) rpm_pulses_per_rev = DecimalField( TRANSLATIONS['rpm_pulses_per_rev']['title'], widget=NumberInput(step='any')) sample_time = DecimalField( TRANSLATIONS['sample_time']['title'], widget=NumberInput(step='any')) # SHT options sht_voltage = StringField(TRANSLATIONS['sht_voltage']['title']) input_mod = SubmitField(TRANSLATIONS['save']['title']) input_delete = SubmitField(TRANSLATIONS['delete']['title']) input_acquire_measurements = SubmitField(lazy_gettext('Acquire Measurements Now')) input_activate = SubmitField(TRANSLATIONS['activate']['title']) input_deactivate = SubmitField(TRANSLATIONS['deactivate']['title']) input_order_up = SubmitField(TRANSLATIONS['up']['title']) input_order_down = SubmitField(TRANSLATIONS['down']['title'])
class ConferenceForm(Form): conference_name = StringField('Conference name', validators=[Required(), Length(1, 128)]) short_name = StringField('Conference short name', validators=[ Required(), Regexp('^[a-zA-Z_]{1,10}\d{4}$', message="Incorrect Format"), Length(1, 64) ]) # website_type = StringField('Website Type', # validators=[Required(), Length(1, 128)]) website_url = StringField('Website URL', validators=[Required()], filters=[process_website_url]) address = StringField('Venue') city = StringField('City', validators=[Length(1, 64)]) state = StringField('State/Province') country = StringField('Country', validators=[Required()]) start = DateField('Start date', validators=[Required()], format='%Y-%m-%d') end = DateField('End date', validators=[Required()], format='%Y-%m-%d') timezone = StringField('Time zone', validators=[Required()]) info = TextAreaField('Conference information') subjects = SelectMultipleField('Subjects', choices=[], validators=[Required()]) tags = StringField('Tags') featured = BooleanField('Featured conference') contact_email = StringField( 'Contact email', validators=[Required(), Length(1, 128), Email()]) contact_phone = StringField('Contact phone number', validators=[Required()]) your_role = StringField('Your role in the conference', validators=[Required()]) contact_name = StringField('Name', validators=[Required()]) affiliation = StringField('Affiliation', validators=[Required()]) requester_contact_phone = StringField('Phone number', validators=[Required()]) requester_website = StringField('Official website', filters=[process_website_url]) referred_by = StringField('Referred by') source_from = SelectField( 'How did you hear about us?', choices=[('Colleague', 'Colleague'), ('Search Engine', 'Search Engine (Google, Bing...)'), ('From a friend', 'From a friend'), ('Link from another page', 'Link from another page'), ('Business associate', 'Business associate')], validators=[Required()]) submit_button = SubmitField('Submit') def __init__(self, **kwargs): super(ConferenceForm, self).__init__(**kwargs) with open(os.path.join(APP_STATIC, 'json/subjects.json')) as f: default_subjects = json.load(f) self.subjects.choices = [(value, value) for value in default_subjects] self.subjects.default = []
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", validators=[ Optional(), Regexp( """^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$""" ), ], ) website = StringField("website", validators=[Optional(), URL()]) image_link = StringField("image_link", validators=[Optional(), URL()]) 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=[Optional(), URL()]) seeking_talent = BooleanField("seeking_talent", validators=[Optional()]) seeking_description = StringField("seeking_description", validators=[Optional()])
class ReusableForm(Form): name = TextField(validators=[validators.required()]) date = TextField('Start', default='Select date', validators=[validators.required()]) languages = SelectMultipleField('Languages', choices=[('en', 'English'), ('it', 'Italian'),('de','German'),('fr', 'French'),('es','Spanish')], validators=[validators.required()]) dataBtn = SubmitField(label='Get Data')
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") image_link = StringField("image_link") genres = SelectMultipleField( # DONE implement enum restriction "genres", validators=[DataRequired()], choices=[(genre, genre.name) for genre in MusicGenre], ) facebook_link = StringField("facebook_link", validators=[URL()])
class __Create_Contract_Form__(FlaskForm) : eservice_list = SelectMultipleField('Pick Enclave Services') pservice_list = SelectMultipleField('Pick Provisioning Services') contract_code_list = RadioField('Contract Code') contract_name = StringField('Contract Object Name', validators=[DataRequired(message='must provide a short name')]) submit = SubmitField('Submit')
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' ) genres = SelectMultipleField( # TODO implement enum restriction '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'), ] ) image_link = StringField( 'image_link', validators=[URL()] ) facebook_link = StringField( 'facebook_link', validators=[URL()] ) website = StringField( 'website', validators=[URL()] ) seeking_talent = BooleanField( 'seeking_talent' ) seeking_description = StringField( 'seeking_description' )
def __init__(self, choices=[], **kwargs): self.choices = choices SelectMultipleField.__init__(self, **kwargs)