class EditProjectForm(FlaskForm): name = StringField(_("Project name"), validators=[DataRequired()]) password = StringField(_("Private code"), validators=[DataRequired()]) contact_email = StringField(_("Email"), validators=[DataRequired(), Email()]) project_history = BooleanField(_("Enable project history")) ip_recording = BooleanField(_("Use IP tracking for project history")) currency_helper = CurrencyConverter() default_currency = SelectField(_("Default Currency"), validators=[DataRequired()]) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.default_currency.choices = [ (currency_name, render_localized_currency(currency_name, detailed=True)) for currency_name in self.currency_helper.get_currencies() ] @property def logging_preference(self): """Get the LoggingMode object corresponding to current form data.""" if not self.project_history.data: return LoggingMode.DISABLED else: if self.ip_recording.data: return LoggingMode.RECORD_IP else: return LoggingMode.ENABLED def save(self): """Create a new project with the information given by this form. Returns the created instance """ project = Project( name=self.name.data, id=self.id.data, password=generate_password_hash(self.password.data), contact_email=self.contact_email.data, logging_preference=self.logging_preference, default_currency=self.default_currency.data, ) return project def update(self, project): """Update the project with the information from the form""" project.name = self.name.data # Only update password if changed to prevent spurious log entries if not check_password_hash(project.password, self.password.data): project.password = generate_password_hash(self.password.data) project.contact_email = self.contact_email.data project.logging_preference = self.logging_preference project.default_currency = self.default_currency.data return project
class FindProductsRangeForm(Form): start = StringField(lazy_gettext('From')) end = StringField(lazy_gettext('To')) status_failed = BooleanField(lazy_gettext('Status Failed')) operation_failed = BooleanField(lazy_gettext('Operation Failed')) variant_id = SelectField(lazy_gettext('Variant')) submit = SubmitField(lazy_gettext('Find')) def __init__(self, variant_choices): Form.__init__(self) self.variant_id.choices = variant_choices
class EditProjectForm(FlaskForm): name = StringField(_("Project name"), validators=[DataRequired()]) password = StringField(_("Private code"), validators=[DataRequired()]) contact_email = StringField(_("Email"), validators=[DataRequired(), Email()]) project_history = BooleanField(_("Enable project history")) ip_recording = BooleanField(_("Use IP tracking for project history")) @property def logging_preference(self): """Get the LoggingMode object corresponding to current form data.""" if not self.project_history.data: return LoggingMode.DISABLED else: if self.ip_recording.data: return LoggingMode.RECORD_IP else: return LoggingMode.ENABLED def save(self): """Create a new project with the information given by this form. Returns the created instance """ project = Project( name=self.name.data, id=self.id.data, password=generate_password_hash(self.password.data), contact_email=self.contact_email.data, logging_preference=self.logging_preference, ) return project def update(self, project): """Update the project with the information from the form""" project.name = self.name.data # Only update password if changed to prevent spurious log entries if not check_password_hash(project.password, self.password.data): project.password = generate_password_hash(self.password.data) project.contact_email = self.contact_email.data project.logging_preference = self.logging_preference return project
class AllergyForm(FlaskForm): A_1 = BooleanField("Dairy") A_2 = BooleanField("Eggs") A_3 = BooleanField("Nuts") A_4 = BooleanField("Shellfish") A_5 = BooleanField("Soy") A_7 = BooleanField("Gluten") A_9 = BooleanField("Seafood")
class User(db.Document, UserMixen): id = IntegerField(primary_key=True) username = StringField(unique=True) email = EmailField(unique=True) image_file = StringField(default='default.jpg') password = StringField(default=True) isAdmin = BooleanField(default=False) posts = Relationship('Post', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class TouliterLogin(FlaskForm): username = StringField('username', validators=[DataRequired()]) password = PasswordField('password', validators=[DataRequired()]) rememberMe = BooleanField('rememberMe', validators=[])
class VenueForm(FlaskForm): 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()] ) website = StringField( 'website',validators=[URL()] ) seeking_talent = BooleanField( 'seeking_talent',validators=[DataRequired()] ) seeking_description = StringField( 'seeking_description' )
class LoginForm(FlaskForm): nickname = StringField('Никнейм', validators=[DataRequired()]) password = PasswordField('Пароль', validators=[DataRequired()]) remember_me = BooleanField('Запомнить меня') submit = SubmitField('Войти')
class KeygenForm(DigestForm): pubkey = TextField('pubkey', secretValidator) email = TextField('email', emailValidator) createUser = BooleanField('createUser')