class UserForm(ModelForm): username_message = 'Letters, numbers and underscores only please.' username = StringField(validators=[ Unique(User.username, get_session=lambda: db.session), DataRequired(), Length(1, 16), Regexp('^\w+$', message=username_message) ]) role = SelectField('Privileges', [DataRequired()], choices=choices_from_dict(User.ROLE, prepend_blank=False)) category = SelectField('Category', [DataRequired()], choices=choices_from_dict(User.TYPE, prepend_blank=False)) region = SelectField('Region', [DataRequired()], choices=choices_from_dict(User.REGION, prepend_blank=False)) telephone = StringField('Telephone number', [DataRequired(), Length(12)]) telephone_2 = StringField('Telephone number 2', [Optional(), Length(12)]) telephone_3 = StringField('Telephone number 3', [Optional(), Length(12)]) description = TextAreaField('Description (EN)', [Optional(), Length(max=200)]) description_ru = TextAreaField('Description (RU)', [Optional(), Length(max=200)]) company_name = StringField('Company name or First Name (EN)', [DataRequired()]) company_name_ru = StringField('Company name or First Name (RU)') active = BooleanField('Yes, allow this user to sign in') confirmed = BooleanField('Confirm this Account')
class CouponForm(ModelForm): redeem_by_msg = 'Datetime must be in the future.' percent_off = IntegerField('Percent off (%)', [Optional(), NumberRange(min=1, max=100)]) amount_off = FloatField('Amount off ($)', [Optional(), NumberRange(min=0.01, max=21474836.47)]) code = StringField('Code', [DataRequired(), Length(1, 32)]) currency = SelectField('Currency', [DataRequired()], choices=choices_from_dict(Currency.TYPES, prepend_blank=False)) duration = SelectField('Duration', [DataRequired()], choices=choices_from_dict(Coupon.DURATION, prepend_blank=False)) duration_in_months = IntegerField('Duration in months', [Optional(), NumberRange( min=1, max=12)]) max_redemptions = IntegerField('Max Redemptions', [Optional(), NumberRange(min=1, max=2147483647)]) redeem_by = DateTimeField('Redeem by', [Optional(), DateRange(min=datetime.now(), message=redeem_by_msg)], format='%Y-%m-%d %H:%M:%S') def validate(self): if not FlaskForm.validate(self): return False result = True code = self.code.data.upper() percent_off = self.percent_off.data amount_off = self.amount_off.data if Coupon.query.filter(Coupon.code == code).first(): unique_error = 'Already exists.' self.code.errors.append(unique_error) result = False elif percent_off is None and amount_off is None: empty_error = 'Pick at least one.' self.percent_off.errors.append(empty_error) self.amount_off.errors.append(empty_error) result = False elif percent_off and amount_off: both_error = 'Cannot pick both.' self.percent_off.errors.append(both_error) self.amount_off.errors.append(both_error) result = False else: pass return result
class BulkChangeScenarioForm(Form): SCOPE = OrderedDict([('all_selected_items', 'All selected items'), ('all_search_results', 'All search results')]) scope = SelectField('Privileges', [DataRequired()], choices=choices_from_dict(SCOPE, prepend_blank=False)) current_scenario = SelectField( 'Change Scenario for All Students', [DataRequired()], choices=choices_from_dict(User.SCENARIO, prepend_blank=False))
class BudgetForm(ModelForm): username = StringField('Account ID', [DataRequired(), ensure_identity_exists]) input_type = SelectField('Input Type', [DataRequired()], choices=choices_from_dict(Budget.INPUT_TYPE, prepend_blank=True)) acct_num = SelectField('Account Number', [DataRequired()], choices=choices_from_dict(Budget.ACCT_NUM, prepend_blank=True)) budget_year = SelectField('Budget Year', [DataRequired()], choices=choices_from_dict(Budget.BUD_YR, prepend_blank=True)) amount = FloatField('Amount ($)', [DataRequired(), NumberRange(min=0.00, max=21474836.47), ensure_float]) description = TextAreaField('Description', [DataRequired(), Length(1, 8192)])
class ClientForm(FlaskForm): region = SelectField(_('Region'), [DataRequired()], choices=choices_from_dict(Client.REGION, prepend_blank=False)) name = StringField(_('Name'), [DataRequired(), Length(3, 254)]) lastname = StringField(_('Lastname'), [DataRequired(), Length(3, 254)]) telephone1 = StringField(_('Telephone'), [DataRequired(), Length(max=12)]) wedding_date = DateField(_('Wedding Date'), [DataRequired()])
class ClientForm(ModelForm): name = StringField("Name", [DataRequired(), Length(3, 254)]) region = SelectField('Region', [DataRequired()], choices=choices_from_dict(Client.REGION, prepend_blank=False)) lastname = StringField('Lastname', [DataRequired(), Length(3, 254)]) nickname = StringField('Nickname', [DataRequired(), Length(max=50)]) telephone1 = StringField('Telephone', [DataRequired(), Length(max=12)]) telephone2 = StringField('Telephone2', [Length(max=12)]) wedding_date = DateField('Wedding Date', [DataRequired()]) wedding_details = TextAreaField('Wedding Details', [DataRequired()]) status = SelectField('Status', [DataRequired()], choices=choices_from_dict(Client.STATUS, prepend_blank=False)) address = StringField('Address', [Length(max=80)]) confirmed = BooleanField('Confirm this Client')
class CouponForm(Form): percent_off = IntegerField('Percent off (%)', [Optional(), NumberRange(min=1, max=100)]) amount_off = FloatField('Amount off ($)', [Optional(), NumberRange(min=0.01, max=21474836.47)]) code = StringField('Code', [DataRequired(), Length(1, 32)]) currency = SelectField('Currency', [DataRequired()], choices=choices_from_dict(Currency.TYPES, prepend_blank=False)) duration = SelectField('Duration', [DataRequired()], choices=choices_from_dict(Coupon.DURATION, prepend_blank=False)) duration_in_months = IntegerField('Duration in months', [Optional(), NumberRange( min=1, max=12)]) max_redemptions = IntegerField('Max Redemptions', [Optional(), NumberRange(min=1, max=2147483647)]) redeem_by = DateTimeField('Redeem by', [Optional()], format='%Y-%m-%d %H:%M:%S') def validate(self): if not Form.validate(self): return False result = True percent_off = self.percent_off.data amount_off = self.amount_off.data if percent_off is None and amount_off is None: empty_error = 'Pick at least one.' self.percent_off.errors.append(empty_error) self.amount_off.errors.append(empty_error) result = False elif percent_off and amount_off: both_error = 'Cannot pick both.' self.percent_off.errors.append(both_error) self.amount_off.errors.append(both_error) result = False else: pass return result
class BulkDeleteForm(Form): SCOPE = OrderedDict([ ('all_selected_items', 'All selected items'), ('all_search_results', 'All search results') ]) scope = SelectField('Privileges', [DataRequired()], choices=choices_from_dict(SCOPE, prepend_blank=False))
class InvitationForm(ModelForm): names = StringField(_('Groom & Bride'), [DataRequired(), Length(max=80)]) telephone = StringField(_('Telephone'), [DataRequired(), Length(max=12)]) wedding_quote = StringField(_('Wedding Place'), [DataRequired()]) wedding_time = TimeField(_('Wedding Time'), [DataRequired()]) wedding_date = DateField(_('Wedding Date'),[DataRequired()]) region = SelectField(_('Region'),[DataRequired()], choices=choices_from_dict(Invitation.REGION, prepend_blank=False))
class CreateForm(FlaskForm): title = StringField('title', [DataRequired(), Length(1, 200)]) gender = SelectField('gender', [DataRequired()], choices=choices_from_dict(Create.GENDER)) category = SelectField('category', [DataRequired()], choices=choices_from_dict(Create.CATEGORY)) subcategory = SelectField('subcategory', [DataRequired()], choices=[(' ', ' ')]) detail1 = StringField('detail1', [DataRequired(), Length(1, 1000)]) detail2 = StringField('detail2', [DataRequired(), Length(1, 1000)]) detail3 = StringField('detail3', [Length(1, 1000)]) detail4 = StringField('detail4', [Length(1, 1000)]) detail5 = StringField('detail5', [Length(1, 1000)]) description = StringField('description', [DataRequired(), Length(1, 8192)])
class SignupForm(ModelForm): company_name = StringField(_('Company Name or Firstname'), [DataRequired(), Length(2, 50)]) email = EmailField(validators=[ DataRequired(), Email(), Unique(User.email, get_session=lambda: db.session) ]) password = PasswordField(_('Password'), [DataRequired(), Length(8, 128)]) confirm_password = PasswordField( _('Confirm Password'), [DataRequired(), EqualTo('password'), Length(8, 128)]) telephone = StringField(_('Telephone number'), [DataRequired(), Length(12)]) category = SelectField(_('Category'), [DataRequired()], choices=choices_from_dict(User.TYPE, prepend_blank=False)) region = SelectField(_('Region'), [DataRequired()], choices=choices_from_dict(User.REGION, prepend_blank=False))
class UserForm(ModelForm): username_message = 'Letters, numbers and underscores only please.' username = StringField(validators=[ Unique(User.username), Optional(), Length(1, 16), Regexp(r'^\w+$', message=username_message) ]) role = SelectField('Privileges', [DataRequired()], choices=choices_from_dict(User.ROLE, prepend_blank=False)) active = BooleanField('Yes, allow this user to sign in')
class UserForm(ModelForm): username_message = 'Letters, numbers and underscores only please.' username = StringField(validators=[ Unique(User.username, get_session=lambda: db.session), Optional(), Length(1, 16), Regexp('^\w+$', message=username_message) ]) role = SelectField('Privileges', [DataRequired()], choices=choices_from_dict(User.ROLE, prepend_blank=False)) active = BooleanField('Yes, allow this user to sign in') email = EmailField(validators=[ Optional(), Email(), Unique(User.email, get_session=lambda: db.session) ]) acct_type = SelectField('Account Type', [DataRequired(), ensure_acct], choices=choices_from_dict(User.ACCT_TYPE, prepend_blank=True))
class InvitationForm(ModelForm): names = StringField('Groom & Bride', [DataRequired(), Length(max=80)]) region = SelectField('Region', [DataRequired()], choices=choices_from_dict(Invitation.REGION, prepend_blank=False)) telephone = StringField('Telephone', [DataRequired()]) wedding_quote = StringField('Wedding Place', [DataRequired()]) wedding_time = TimeField('Wedding Time', [DataRequired()]) wedding_date = DateField('Wedding Date', [DataRequired()]) payment = DecimalField('Price', [DataRequired()]) photo = FileField('Upload a Photo', [ FileAllowed(['jpg', 'JPG', 'jpeg', 'JPEG', 'png', 'PNG'], 'Image only!') ]) confirmed = BooleanField('Confirm Invitation')
class UserForm(ModelForm): username_message = 'Letters, numbers and underscores only please.' username = StringField(validators=[ Unique(User.username, get_session=lambda: db.session), DataRequired(), Length(1, 32), Regexp('^\w+$', message=username_message) ]) role = SelectField('Privileges', [DataRequired()], choices=choices_from_dict(User.ROLE, prepend_blank=False)) active = BooleanField('Yes, allow this user to sign in') deleted = BooleanField('User is soft deleted')
class UserForm(ModelForm): username_message = 'Letters, numbers and underscores only please.' username = StringField(validators=[ Unique(User.username, get_session=lambda: db.session), Optional(), Length(1, 16), # Part of the Python 3.7.x update included updating flake8 which means # we need to explicitly define our regex pattern with r'xxx'. Regexp(r'^\w+$', message=username_message) ]) role = SelectField('Privileges', [DataRequired()], choices=choices_from_dict(User.ROLE, prepend_blank=False)) active = BooleanField('Yes, allow this user to sign in')
class UserForm(ModelForm): username_message = '仅限字母,数字,中文和下划线组合' username = StringField(validators=[ Unique(User.username, get_session=lambda: db.session), DataRequired(), Length(1, 16), Regexp('^\w+$', message=username_message) ]) role = SelectField('角色', [DataRequired()], choices=choices_from_dict(User.ROLE, prepend_blank=False)) email = StringField('E-mail', [DataRequired()]) phone = StringField('手机', [DataRequired()])
class UserForm(ModelForm): username_message = 'Letters, numbers and underscores only please.' money = IntegerField() current_scenario = SelectField('Current Scenario', [DataRequired()], choices=choices_from_dict( User.SCENARIO, prepend_blank=False)) supplement = BooleanField('Yes, give this student supplemental materials') needs_help = BooleanField('This student has requested help') finished_scenario = BooleanField('This student has finished the scenario') active = BooleanField('Yes, allow this user to sign in')
class UserForm(ModelForm): username_message = 'Letters, numbers and underscores only please.' coins = IntegerField( 'Coins', [DataRequired(), NumberRange(min=1, max=2147483647)]) username = StringField(validators=[ Unique(User.username, get_session=lambda: db.session), Optional(), Length(1, 16), Regexp('^\w+$', message=username_message) ]) role = SelectField('Privileges', [DataRequired()], choices=choices_from_dict(User.ROLE, prepend_blank=False)) active = BooleanField('Yes, allow this user to sign in')
class MeterForm(ModelForm): sequence_number_message = 'Sequence number is required and must be unique.' serial_number_message = 'Serial number is required and must be unique.' phone_number_message = 'Phone number is required and must be unique.' sequence_number = StringField(validators=[ Unique(Meter.sequence_number, get_session=lambda: db.session), DataRequired(), Length(1, 16), Regexp('^\w+$', message=sequence_number_message) ]) serial_number = QuerySelectField(query_factory=serial_query) phone_number = QuerySelectField(query_factory=phone_query) customer_name = StringField('Customer Name', [Optional(), Length(1, 256)]) branch = StringField('Branch', [Optional(), Length(1, 256)]) zone = StringField('Zone', [Optional(), Length(1, 256)]) initial_reading = StringField('Initial Reading', [Optional(), Length(1, 256)]) lat_long = StringField('Lat Long', [Optional(), Length(1, 256)]) hes = SelectField('HES APP', [DataRequired()], choices=choices_from_dict(Meter.ROLE, prepend_blank=False)) active = BooleanField('Yes, allow to collect data from this meter')
class UpdateLocaleForm(Form): locale = SelectField('Language preference', [DataRequired()], choices=choices_from_dict(LANGUAGES, prepend_blank=False))