class FinGoodsForm(FlaskForm): product_category = QuerySelectField('product_category', validators=[InputRequired()], query_factory=prod_cat_choice, allow_blank=False, get_label='cat') fabric_combo = QuerySelectField('fabric_combo', validators=[InputRequired()], query_factory=fab_comb_choice, allow_blank=False, get_label='comb') print_tech = QuerySelectField('print_tech', validators=[InputRequired()], query_factory=print_tech_choice, allow_blank=False, get_label='tech') design = QuerySelectField('design', validators=[InputRequired()], query_factory=design_choice, allow_blank=False, get_label='des') uom = QuerySelectField('uom', validators=[InputRequired()], query_factory=uom_choice, allow_blank=False, get_label='measure') alt_name = StringField('alt_name') fin_submit = SubmitField('fin_submit') fin_update = SubmitField('fin_update')
class StudentSearchForm(Form): id = IntegerField('Номер студенческого билета', [validators.NumberRange(min=1), validators.Optional()]) surname = StringField('Фамилия', [ validators.Length(min=2, max=Student.surname.property.columns[0].type.length), validators.Optional() ]) firstname = StringField('Имя', [ validators.Length( min=2, max=Student.firstname.property.columns[0].type.length), validators.Optional() ]) middlename = StringField('Отчество', [ validators.Length( min=2, max=Student.middlename.property.columns[0].type.length), validators.Optional() ]) status = QuerySelectField('Состояние', query_factory=lambda: StudentStates, get_pk=lambda s: s, get_label=lambda s: StudentStateDict[s], blank_text='Не указано', allow_blank=True, validators=[validators.Optional()]) semester = IntegerField( 'Семестр', [validators.NumberRange(min=1, max=10), validators.Optional()]) stud_group = QuerySelectField( 'Группа', query_factory=lambda: db.session.query(StudGroup).filter( StudGroup.active).order_by(StudGroup.year, StudGroup.semester, StudGroup.num, StudGroup.subnum).all(), get_pk=lambda g: g.id, get_label=lambda g: "%d курс группа %s" % (g.course, g.num_print), blank_text='Неизвестно', allow_blank=True) alumnus_year = IntegerField('Учебный год выпуск', [ validators.NumberRange(min=2000, max=datetime.now().year + 1), validators.Optional() ]) expelled_year = IntegerField('Учебный год отчисления', [ validators.NumberRange(min=2000, max=datetime.now().year + 1), validators.Optional() ]) login = StringField('Login') card_number = IntegerField( 'Номер карты (пропуска)', [validators.Optional(), validators.NumberRange(min=1)]) group_leader = SelectField('Староста', choices=[('any', 'Не важно'), ('yes', 'Да'), ('no', 'Нет')]) button_search = SubmitField('Поиск')
class CurriculumUnitForm(ModelForm): class Meta: model = CurriculumUnit stud_group = QuerySelectField( 'Группа', query_factory=lambda: db.session.query(StudGroup).filter( StudGroup.active).order_by(StudGroup.year, StudGroup.semester, StudGroup.num, StudGroup.subnum).all(), get_pk=lambda g: g.id, get_label=lambda g: "%d курс группа %s" % (g.course, g.num_print), allow_blank=False) teacher = QuerySelectField( 'Преподаватель', query_factory=lambda: db.session.query(Teacher).order_by( Teacher.surname, Teacher.firstname, Teacher.middlename).all(), get_pk=lambda t: t.id, get_label=lambda t: t.full_name_short, blank_text='Не указан', allow_blank=True, validators=[validators.DataRequired()]) subject = QuerySelectField('Предмет', query_factory=lambda: db.session.query(Subject). order_by(Subject.name).all(), get_pk=lambda s: s.id, get_label=lambda s: s.name, blank_text='Не указан', allow_blank=True, validators=[validators.DataRequired()]) hours_att_1 = IntegerField( 'Часов на 1-ю аттестацию', [validators.NumberRange(min=1), validators.DataRequired()]) hours_att_2 = IntegerField( 'Часов на 2-ю аттестацию', [validators.NumberRange(min=1), validators.DataRequired()]) hours_att_3 = IntegerField( 'Часов на 3-ю аттестацию', [validators.NumberRange(min=1), validators.DataRequired()]) mark_type = QuerySelectField('Тип отчётности', query_factory=lambda: MarkTypes, get_pk=lambda t: t, get_label=lambda t: MarkTypeDict[t], blank_text='Не указан', allow_blank=True, validators=[validators.DataRequired()]) button_save = SubmitField('Сохранить') button_delete = SubmitField('Удалить')
class InterfaceFrom(Form): interface_body_type = "" interface_name = StringField(u'接口名称', [length(min=0, max=200),data_required(message= u'接口名不能为空')]) interface_url = StringField(u'接口url', [length(min=0), data_required(message= u'接口url不能为空')]) interface_method = SelectField(u"接口方法", choices=Method) runner_setting = QuerySelectField(u"当前环境", query_factory=get_runner_setting) module = QuerySelectField(u"所属模块", query_factory=get_all_module) interface_header = FieldList(FormField(HeaderForm), min_entries=1) interface_query = FieldList(FormField(QueryForm), min_entries=1) interface_data = FieldList(FormField(BodyForm), min_entries=1) interface_json = StringField() interface_desc = TextAreaField(u"接口描述") is_active = BooleanField('is_active')
class StudentForm(_PersonForm, ModelForm): class Meta: model = Student include_primary_keys = True id = IntegerField('Номер студенческого билета', [ validators.DataRequired(), validators.NumberRange(min=1), Unique(Student.id, get_session=lambda: db.session, message='Номер студенческого билета занят') ]) status = QuerySelectField('Состояние', query_factory=lambda: StudentStates, get_pk=lambda s: s, get_label=lambda s: StudentStateDict[s], allow_blank=False, validators=[validators.DataRequired()]) semester = IntegerField( 'Семестр', [validators.NumberRange(min=1, max=10), validators.Optional()]) stud_group = QuerySelectField( 'Группа', query_factory=lambda: db.session.query(StudGroup).filter( StudGroup.active).order_by(StudGroup.year, StudGroup.semester, StudGroup.num, StudGroup.subnum).all(), get_pk=lambda g: g.id, get_label=lambda g: "%d курс группа %s" % (g.course, g.num_print), blank_text='Не указана', allow_blank=True) alumnus_year = IntegerField('Учебный год выпуск', [ validators.NumberRange(min=2000, max=datetime.now().year + 1), validators.Optional() ]) expelled_year = IntegerField('Учебный год отчисления', [ validators.NumberRange(min=2000, max=datetime.now().year + 1), validators.Optional() ]) card_number = IntegerField('Номер карты (пропуска)', [ validators.Optional(), validators.NumberRange(min=1), Unique(Student.card_number, get_session=lambda: db.session, message='Номер занят') ]) group_leader = BooleanField('Староста') button_save = SubmitField('Сохранить') button_delete = SubmitField('Удалить')
class CityForm(FlaskForm): city = StringField('city', validators=[InputRequired()]) state = QuerySelectField('state', validators=[InputRequired()], query_factory=state_choice, allow_blank=False, get_label='state') country = QuerySelectField('country', validators=[InputRequired()], query_factory=country_choice, allow_blank=False, get_label='country') city_submit = SubmitField('city_submit') city_update = SubmitField('city_update')
class DeviceForm(FlaskForm): name = StringField('Name', validators=[DataRequired()]) ip = StringField('IP Address', validators=[DataRequired(), IPAddress()]) # devicetype = StringField('Type') devicetype = QuerySelectField(query_factory=devicetype_query, allow_blank=True) location = QuerySelectField(query_factory=location_query, allow_blank=True) # location = StringField('Location') submit = SubmitField('Submit') def validate_ip(self, ip): device = Device.query.filter_by(ip=ip.data).first() if device is not None: raise ValidationError( 'That ip is already entered. Please choose a different one.')
class IngredientForm(FlaskForm): ''' The IngredientForm class defines the ingredient specific fields ''' name = StringField('Naam: ', validators=[ DataRequired(), Length(max=128, message="Max length=%(max)d") ]) default_unit = QuerySelectField('Eenheid: ', query_factory=get_unit_list, allow_blank=False, get_label='name') default_amount = DecimalField('Hoeveelheid: ', places=2) picture_file_picker = FileField( 'Foto: ', validators=[FileAllowed(['jpg', 'jpeg', 'png'], 'Images only!')]) def __init__(self, ingredient: list = None, *args, **kwargs): ''' Modified constructure to pre-populate the name and description field to allow updates to existing records ''' super().__init__(*args, **kwargs) if ingredient: self.name.data = ingredient.name """ TO DO - Update value select field automatically """ self.default_unit.data = ingredient.default_unit self.default_amount.data = ingredient.default_amount
class RecipeForm(FlaskForm): ''' The RecipeForm class defines the recipe specific fields ''' id = IntegerField(id="recipe_id_field") name = StringField('Naam: ', validators=[ DataRequired(), Length(max=128, message="Max length=%(max)d") ]) category = QuerySelectField('Categorie:', query_factory=get_category_list, allow_blank=False, get_label='name') preparation = TextAreaField('Bereidingswijze:', render_kw={ 'cols': 22, 'rows': 5 }) picture_file_picker = FileField( 'Foto:', validators=[FileAllowed(['jpg', 'jpeg', 'png'], 'Images only!')]) def __init__(self, recipe: list = None, *args, **kwargs): ''' Modified constructure to pre-populate the name, category and preparation fields to allow updates to existing records ''' super().__init__(*args, **kwargs) if recipe: self.id.data = recipe.id self.name.data = recipe.name self.category.data = recipe.category self.preparation.data = recipe.preparation
class Disposition(ModelForm, FormlyAttributes, DataSerializer): class Meta: model = alch.Disposition include_primary_keys = True only = ["explanation", "disposedIn", "reconsiderIn", "plannedFor", "dispositionLastModified", "dispositionLastModifiedBy"] disposedIn = FiscalQuarterField(u"disposed", validators=[Required()], transform_data=True, description=u"In which planning cycle was this disposition made? " "Changing this date and pressing save will create a new " "disposition record. If you don't change the date, then " "you will update the record you are looking at.") disposition = QuerySelectField(u"disposition", validators=[Required()], query_factory=disposition_choices, description=u"What decision was made during the planning cycle with " "respect to this project?") explanation = TextAreaField(u"explanation", description=u"State the reasons behind the disposition decision.") reconsiderIn = FiscalQuarterField(u"reconsider", description=u"For a deferred project, when will it be considered " "again?") plannedFor = FiscalQuarterField(u"start", description=u"Estimated dates for the start and finish of work on the " "project.") # We need a table-specific handle for these two generic columns since # otherwise the search will never get to just one column dispositionLastModified = DateTimeField(label=u"last updated", format="%Y-%m-%dT%H:%M:%SZ") dispositionLastModifiedBy = StringField(label=u"last updated by") def __init__(self, *args, **kwargs): super(Disposition, self).__init__(*args, **kwargs) read_only(self.dispositionLastModified) read_only(self.dispositionLastModifiedBy)
class EditForm(FF): product_name = StringField('p_name', validators=[DataRequired(), Length(max=64)]) product_type = QuerySelectField('p_type', query_factory=Prodquery, allow_blank=False, get_label='prod_type') product_price = FloatField('p_price') product_unit = QuerySelectField('p_unit_type', validators=[DataRequired()], query_factory=Prodquery, allow_blank=False, get_label='prod_unit_scale') product_stock = IntegerField('p_stock') submit = SubmitField('Save changes')
class TestInterfaceCaseFrom(Form): testcase_body_type = "" interface_url = StringField( u'接口url', [length(min=0), data_required(message=u'接口url不能为空')]) testcase_name = StringField(u'接口名称', [data_required(message=u'接口名不能为空')]) module = QuerySelectField(u"所属模块", query_factory=get_all_module) runner_setting = QuerySelectField(u"当前环境", query_factory=get_runner_setting) testcase_method = SelectField(u"接口方法", choices=Method) testcase_header = FieldList(FormField(HeaderForm), min_entries=1) testcase_query = FieldList(FormField(QueryForm), min_entries=1) testcase_data = FieldList(FormField(BodyForm), min_entries=1) testcase_json = StringField() testcase_verification = FieldList(FormField(VerificationForm), min_entries=1)
class EditUserForm(FlaskForm): profile_id = HiddenField('original_profile_id') first_name = StringField(_l('Nombre'), validators=[DataRequired()]) last_name = StringField(_l('Apellido'), validators=[DataRequired()]) email = StringField(_l('Email'), validators=[DataRequired(), Email()]) perfil = QuerySelectField(query_factory=profile_query, allow_blank=False, get_label='name', widget=Select2Widget(), render_kw={'autocomplete': False}) password = PasswordField(_l('Contraseña (dejar en blanco para mantener)'), render_kw={'autocomplete': False}) password2 = PasswordField(_l('Repetir Contraseña'), validators=[EqualTo('password')], render_kw={'autocomplete': False}) submit = SubmitField(_l('Guardar Cambios')) def __init__(self, original_email, *args, **kwargs): super(EditUserForm, self).__init__(*args, **kwargs) self.original_email = original_email def validate_email(self, email): if email.data != self.original_email: user = User.query.filter_by(email=email.data).first() if user is not None: raise ValidationError( _('E-mail ya registrado, por favor, use un e-mail diferente.' ))
class Add_Book(FlaskForm): title = StringField('Book Title', validators=[DataRequired()]) year = StringField('Year Published', validators=[DataRequired()]) book_cover = StringField('URL link for book cover picture', validators=[DataRequired()]) description = TextAreaField('Book description ', validators=[DataRequired()]) publisher = QuerySelectField(query_factory=choice_publisher, allow_blank=True, get_label='publisherName') category = QuerySelectField(query_factory=choice_category, allow_blank=True, get_label='Name') author = QuerySelectField(query_factory=choice_author, allow_blank=True, get_label='full_name') submit = SubmitField('Add')
class VoteForm(Form): team = QuerySelectField( 'Team', query_factory=all_teams, allow_blank=True, blank_text='Select a Team', validators=[DataRequired(message="You must select a team.")]) reason = StringField('Reason', validators=[Optional(), Length(max=140)])
class OtherMatForm(FlaskForm): mat = StringField('mat', validators=[InputRequired()]) uom = QuerySelectField('uom', validators=[InputRequired()], query_factory=uom_choice, allow_blank=False, get_label='measure') mat_submit = SubmitField('mat_submit') mat_update = SubmitField('mat_update')
class AccessoriesForm(FlaskForm): acc = StringField('acc', validators=[InputRequired()]) uom = QuerySelectField('uom', validators=[InputRequired()], query_factory=uom_choice, allow_blank=False, get_label='measure') acc_submit = SubmitField('acc_submit') acc_update = SubmitField('acc_update')
class DishIngredForm(ModelForm): class Meta: model = Dish_Ingredient dish = QuerySelectField('Блюдо', query_factory=lambda: mydb.session.query(Dish).all(), get_pk=lambda g: g.id_dish, get_label=lambda g: "%s" % (g.dish_name)) # id_dish = IntegerField('Айди блюда', [validators.DataRequired()]) ingred = QuerySelectField('Ингредиент', query_factory=lambda: mydb.session.query(Ingredient).all(), get_pk=lambda g: g.id_ingred, get_label=lambda g: "%s" % (g.ingred_name)) unit = QuerySelectField('Единица измерения', query_factory=lambda: mydb.session.query(Unit).all(), get_pk=lambda g: g.id_unit, get_label=lambda g: "%s" % (g.unit_name)) sum = IntegerField('Количество', [validators.DataRequired()]) button_save = SubmitField('Сохранить')
class Project(ModelForm, FormlyAttributes, DataSerializer): class Meta: model = alch.Project include_primary_keys = True only = ["proj_manager", "tech_manager", "project_url", "startedOn", "finishedOn", "projectLastModified", "projectLastModifiedBy"] project_url = StringField(u"project url", description=u"The full URL of the project page. The project page is " "where project status is reported, such as on the CPT " "project wiki. Limited to 255 characters.") progress = QuerySelectField(u"progress", query_factory=progress_choices, description=u"Where is this project in the Project Management " "Framework?") proj_manager = StringField(u"project manager", description=u"Name of the project manager.") tech_manager = StringField(u"technical manager", description=u"Name of the technical manager.") proj_visibility = QuerySelectField(u"project visibility", query_factory=proj_visibility_choices, description=u"Categorize visibility for running this project. Will " "it be run as an integrated schedule project, a regular " "project, or as some other (lower visibility) type?") startedOn = DateField(u"started", description=u"The actual date on which the project started running, " "i.e., the first day of the definition phase.") finishedOn = DateField(u"finished", description=u"The date on which the project was successfully ended, " "i.e., the last day of the closeout phase of the " "project. Format as above.") # We need a table-specific handle for these two generic columns since # otherwise the search will never get to just one column projectLastModified = DateTimeField(u"last updated", format="%Y-%m-%dT%H:%M:%SZ") projectLastModifiedBy = StringField(u"last updated by") def __init__(self, *args, **kwargs): super(Project, self).__init__(*args, **kwargs) read_only(self.projectLastModified) read_only(self.projectLastModifiedBy)
class AssignForm(Default): subjects = StringField( 'Asignatura', validators=[DataRequired()] ) profe = QuerySelectField( 'Profesores', validators=[DataRequired()], query_factory=profesor_query, allow_blank=True )
class ExploreForm(FlaskForm): service = QuerySelectField('What service would you like to report?', query_factory=service_query, allow_blank=True, blank_text='Enter a Service', get_label='title', validators=[DataRequired()]) city = SelectField('What city are you located in?', choices=city_choices, validators=[DataRequired()]) submit = SubmitField('Submit')
class MoveDescriptionForm(Form, SaveChangesMixin): # field for destination project destination = QuerySelectField('Move this description to project', query_factory=qf, get_label='name') # optionally leave a copy of the description attached to this project copy = BooleanField( 'Leave a copy of the description attached to its current project', default=False)
class PostForm(FlaskForm): service = QuerySelectField(query_factory=service_query, allow_blank=True, blank_text='Select a Service', get_label='title', validators=[DataRequired()]) company = QuerySelectField(query_factory=company_query, allow_blank=True, blank_text='Select a Company', get_label='company_display') price = DecimalField('What price did you pay?', validators=[DataRequired()]) rating = SelectField('Leave a rating ', choices=[('1', '1 Star'), ('2', '2 Stars'), ('3', '3 Stars'), ('4', ' 4 Stars'), ('5', '5 Stars')], validators=[DataRequired()]) post = TextAreaField('Leave a Review', validators=[DataRequired(), Length(min=1, max=140)]) submit = SubmitField('Submit')
class EditDeviceForm(FlaskForm): name = StringField('Name', validators=[DataRequired()]) ip = StringField('IP Address', validators=[DataRequired(), IPAddress()]) # devicetype = StringField('Type') devicetype = QuerySelectField(query_factory=devicetype_query, allow_blank=True) location = QuerySelectField(query_factory=location_query, allow_blank=True) # location = StringField('Location') submit = SubmitField('Submit') def __init__(self, original_ip, *args, **kwargs): super(EditDeviceForm, self).__init__(*args, **kwargs) self.original_ip = original_ip def validate_ip(self, ip): if ip.data != self.original_ip: ip = Device.query.filter_by(ip=self.ip.data).first() if ip is not None: raise ValidationError( 'That ip is already entered. Please choose a different one.' )
class EnterForm(FF): product_name = StringField('p_name', validators=[DataRequired(), Length(max=64)]) product_unit = SelectField('p_unit_type', validators=[DataRequired()], choices=[('Caixa', 'Caixa')]) product_price = FloatField('p_price', validators=[DataRequired()]) prod_id = IntegerField('p_id', validators=[DataRequired()]) product_type = QuerySelectField('p_type', query_factory=Prodquery, allow_blank=False, get_label='prod_type') product_stock = IntegerField('p_stock', validators=[DataRequired()]) submit = SubmitField('Insert new product')
class SendAirtime(FlaskForm): to = QuerySelectField(query_factory=numbers_query, allow_blank=False, get_label='alias') airtime_value = IntegerField( 'Airtime Value', render_kw={'placeholder': ' Ksh 5 - 4000'}, validators=[ DataRequired(), NumberRange(min=1, max=4000, message='Airtime value must be between Ksh 5 - 4000') ]) submit_send_airtime = SubmitField('Send')
class ChildForm(ModelForm): name = fields.StringField(validators=[validators.DataRequired()]) age = fields.IntegerField(validators=[validators.Optional()]) height = fields.DecimalField(places=2, validators=[validators.Optional()]) parent = QuerySelectField(query_factory=parents, allow_blank=True, blank_text="Please select...") class Meta: model = Child @classmethod def get_session(cls): from starlette_core.database import Session return Session()
class SubjectsForm(Default): name = StringField( 'Nombre', validators=[DataRequired()] ) profe = QuerySelectField( 'Profesores', query_factory=profesor_query, allow_blank=True ) calificacion = SelectField('Calificación', choices=lista_calificacion ) estado = BooleanField('Marcar como cursada')
class RegisterForm(FF): username = StringField('username', validators=[DataRequired(), Length(max=16)]) password = PasswordField('password', validators=[DataRequired()]) c_password = PasswordField('confirm password', validators=[DataRequired()]) loja_associada = QuerySelectField('loja', validators=[DataRequired()], query_factory=Lojaquery, allow_blank=False, get_label='store_name') tipo = SelectField('permissions', validators=[DataRequired()], choices=[(0, 'Admin'), (1, 'Funcionário'), (2, 'Matriz')]) submit = SubmitField('Register new account')
class StudentsUnallocatedForm(Form): semester = HiddenField() students_selected = QuerySelectMultipleField( 'Студенты', get_pk=lambda s: s.id, get_label=lambda s: "%d %s" % (s.id, s.full_name), widget=ListWidget(prefix_label=False), option_widget=CheckboxInput()) stud_group = QuerySelectField( 'Группа в которую нужно перевести', get_pk=lambda g: g.id, get_label=lambda g: g.num_print, blank_text='Не указана', allow_blank=True, validators=[validators.DataRequired('Укажите группу')]) button_transfer = SubmitField('Перевести в выбранную группу')