示例#1
0
class CreateTaskForm(Form):
    name = TextField('Task Name', validators=[Required()])
    info = TextField('Info')
    start_date = DateField('Start Date',
                           validators=[Required()],
                           format='%d-%m-%Y')
    end_date = DateField('End Date',
                         validators=[Required()],
                         format='%d-%m-%Y')
    team = TextField('Team', validators=[Required()])
示例#2
0
class book_edit_form(Form):
    title = TextField("Title")
    imprint = TextField("Imprint")
    eisbn = TextField("eISBN", validators=[Optional()])
    pisbn = TextField("pISBN", validators=[Optional()])
    language = TextField("Language")
    list_price = DecimalField("List Price", places=2, validators=[Optional()])
    currency = SelectField(
        "Currency",
        choices=[(g, g)
                 for g in ['none', 'USD', 'EUR', 'GBP', 'CAD', 'CNY', 'JPY']])
    release_date = DateField("Release Date",
                             validators=[Optional()],
                             format='%m/%d/%Y')
    publishing_date = DateField("Publishing Date",
                                validators=[Optional()],
                                format='%m/%d/%Y')
    description = TextAreaField("Description")
    bisac = TextField("BISAC")
    bic = TextField("BIC")
    #TODO: Fix this, this needs to be a list.
    territory = SelectField("Countries to sell in",
                            choices=[('none', 'none'), ('US', 'US'),
                                     ('GB', 'GB'), ('FR', 'FR'), ('IT', 'IT'),
                                     ('CN', 'CN'), ('JP', 'JP'), ('ES', 'ES'),
                                     ('IE', 'IE'), ('DE', 'DE')],
                            validators=[Optional()])
    adult = BooleanField("Is this an adult book?")
    edition = TextField("Edition")
    series = SelectField("Series", coerce=int)
    volume = TextField("Volume")
    authors = SelectMultipleField("Authors", coerce=int)
    editors = SelectMultipleField("Editors", coerce=int)
    illustrators = SelectMultipleField("Illustrators", coerce=int)
    contributors = SelectMultipleField("Contributors", coerce=int)
    translators = SelectMultipleField("Translators", coerce=int)

    def validate_publishing_date(self, field):
        if field.data > self.release_date.data:
            raise ValidationError(
                "The publishing date must be before or equal to the release date."
            )

    def is_isbn_valid(self, isbn):
        if not isValid(isbn):
            raise ValidationError("The ISBN entered is not valid.")

    def validate_eisbn(self, field):
        self.is_isbn_valid(field.data)

    def validate_pisbn(self, field):
        self.is_isbn_valid(field.data)
示例#3
0
class StockInForm(Form):
    sku = QuerySelectField(u'商品',query_factory=skus,get_label='name')
    store_id = SelectField(u"仓库", [AnyOf([str(val) for val in STORES.keys()])],choices=[(str(val), label) for val, label in STORES.items()])
    c = SelectField(u"入库方式", [AnyOf([str(val) for val in STOCK_IN_CATEGORIES_IDs])],choices=[(str(val), STOCK_IN_CATEGORIES[val]) for val in STOCK_IN_CATEGORIES_IDs])
    shelf_number = TextField(u'货架号')
    code = TextField(u'入库凭证')
    made_in = TextField(u'产地')
    purchase_price = FloatField(u'进货价',default=0.0)
    mfg_date = DateField(u'生产日期',[Optional()])
    exp_date = DateField(u'有效期至',[Optional()])
    quantity = IntegerField(u'入库数量',[validate_gte_0])
    order_id = TextField(u'关联订单号')
    remark = TextAreaField(u'备注')
示例#4
0
class AddTask(Form):
    task_id = IntegerField('Priority')
    name = TextField('Task Name', validators=[Required()])
    due_date = DateField('Date Due (mm/dd/yyyy)',
                         validators=[Required()],
                         format='%m/%d/%Y')
    priority = SelectField('Priority',
                           validators=[Required()],
                           choices=[('1', '1'), ('2', '2'), ('3', '3'),
                                    ('4', '4'), ('5', '5')])
    status = IntegerField('Status')
    posted_date = DateField('Posted Date (mm/dd/yyyy)',
                            validators=[Required()],
                            format='%m/%d/%Y')
示例#5
0
class EditReleaseForm(Form):
    shippedAtDate = DateField('Shipped date',
                              format='%Y/%m/%d',
                              validators=[
                                  validators.optional(),
                              ])
    shippedAtTime = StringField('Shipped time')
    isSecurityDriven = BooleanField('Is Security Driven ?')
    description = TextAreaField('Description')
    isShipped = BooleanField('Is Shipped ?')

    def validate_isShipped(form, field):
        if form.isShipped.data:
            dt = form.shippedAt

            if (not dt) or (dt > datetime.now()):
                raise ValidationError('Invalid Date for Shipped release')

    @property
    def shippedAt(self):
        dateAndTime = None

        if self.shippedAtDate.data:
            dt = self.shippedAtDate.data
            tm = datetime.strptime(self.shippedAtTime.data, '%H:%M:%S').time()
            dateAndTime = datetime.combine(dt, tm)

        return dateAndTime
示例#6
0
class BillForm(Form):
    date = DateField(_("Date"), validators=[Required()], default=datetime.now)
    what = TextField(_("What?"), validators=[Required()])
    payer = SelectField(_("Payer"), validators=[Required()], coerce=int)
    amount = CommaDecimalField(_("Amount paid"), validators=[Required()])
    payed_for = SelectMultipleField(_("For whom?"),
            validators=[Required()], widget=select_multi_checkbox, coerce=int)
    submit = SubmitField(_("Submit"))
    submit2 = SubmitField(_("Submit and add a new one"))

    def save(self, bill, project):
        bill.payer_id = self.payer.data
        bill.amount = self.amount.data
        bill.what = self.what.data
        bill.date = self.date.data
        bill.owers = [Person.query.get(ower, project)
            for ower in self.payed_for.data]

        return bill

    def fill(self, bill):
        self.payer.data = bill.payer_id
        self.amount.data = bill.amount
        self.what.data = bill.what
        self.date.data = bill.date
        self.payed_for.data = [int(ower.id) for ower in bill.owers]

    def set_default(self):
        self.payed_for.data = self.payed_for.default

    def validate_amount(self, field):
        if field.data < 0:
            field.data = abs(field.data)
        elif field.data == 0:
            raise ValidationError(_("Bills can't be null"))
示例#7
0
class ProfileForm(Form):
    next = HiddenField()
    name = TextField(
            label = _("Username"),
            validators = [
                Required(),
                Length(USERNAME_LEN_MIN, USERNAME_LEN_MAX),
                ],
            description = u"Combination of letters/digits/underscore, at least %s characters." % USERNAME_LEN_MIN,
            )
    email = EmailField(
            label = _('Email'), 
            validators = [Email()],
            )
    created_time = DateField(
            label = _('Created time'),
            )
    role_id = RadioField(
            label = "Role",
            validators = [AnyOf([str(val) for val in USER_ROLE.keys()])],
            choices = [(str(val), label) for val, label in USER_ROLE.items()],
            )
    status_id = RadioField(
            label = "Status",
            validators = [AnyOf([str(val) for val in USER_STATUS.keys()])],
            choices = [(str(val), label) for val, label in USER_STATUS.items()],
            )
    real_name = TextField(
            label = _('Real name'),
            validators = [
                Length(REALNAME_LEN_MIN, REALNAME_LEN_MAX),
                ]
            )
    age = IntegerField(
            label = _('Age'), 
            validators = [NumberRange(AGE_MIN, AGE_MAX)],
            )
    phone = TelField(
            label = _('Phone'), 
            )
    url = URLField(
            label = _('URL'), 
            validators = [URL()],
            )
    deposit = DecimalField(
            label = _('Deposit'), 
            validators = [NumberRange(DEPOSIT_MIN, DEPOSIT_MAX)],
            )
    location = TextField(
            label = _('Location'), 
            validators = [Length(max=50)]
            )
    bio = TextAreaField(
            label = _('Bio'), 
            validators = [Length(max=1024)]
            )
    submit = SubmitField(_('Save'))
示例#8
0
class SeasonCycleForm(Form):
	leaguename = TextField('League Name', [validators.Required()],
							description=u'League Name')
	cyclename = TextField('Cycle Name', [validators.Required(), 
						   validators.length(min=6, max=25)],
						   description=u'Season Cycle Description')
	num_of_teams = IntegerField('Number Of Teams', [validators.Required()],
								description=u'Max # Teams')
	home_region = TextField('League Name', [validators.Required()],
							description=u'Home Region')
	fee_resident = FloatField('Resident Fee', [validators.Required()],
							  description=u'Resident Fee')
	fee_nonresident = FloatField('Resident Fee', [validators.Optional()],
								  description=u'Nonresident Fee (Optional)') 
	reg_start = DateField('Registration Starts', [validators.Required(message=(u'start date: mm/dd/yyyy'))], 
						   format= '%m/%d/%Y', description=u'Registration Starts (mm/dd/yyyy)')
	reg_end = DateField('Registration Ends', [validators.Required(message= (u'end date: mm/dd/yyyy'))], 
						 format= '%m/%d/%Y', description=u'Registration Ends (mm/dd/yyyy)')
示例#9
0
class UserForm(Form):
    next = HiddenField()
    role_id = RadioField(u"Role",
                         [AnyOf([str(val) for val in USER_ROLE.keys()])],
                         choices=[(str(val), label)
                                  for val, label in USER_ROLE.items()])
    status_id = RadioField(u"Status",
                           [AnyOf([str(val) for val in USER_STATUS.keys()])],
                           choices=[(str(val), label)
                                    for val, label in USER_STATUS.items()])
    # A demo of datepicker.
    created_time = DateField(u'Created time')
    submit = SubmitField(u'Save')
示例#10
0
class CreateTaskForm(Form):
    name = TextField(
        'Task Name',
        description='Enter a unique and descriptive name for this task',
        validators=[Required()])
    info = TextAreaField(
        'Description',
        description='Enter a detailed description of this project')
    start_date = DateField(
        'Start Date',
        description='Enter the date when this project will start',
        validators=[Required()],
        format='%d-%m-%Y')
    end_date = DateField(
        'End Date',
        description='Enter the date when this project will end',
        validators=[Required()],
        format='%d-%m-%Y')
    team = TextField(
        'Team',
        description=
        'Begin typing names of the people who will be involved with this project',
        validators=[Required()])
示例#11
0
class GameForm(Form):	
	all_teams = model.current_teams()
		    	
	game_date = DateField('Game Date', [validators.Required(message= (u'Game Date: mm/dd/yyyy'))], 
						 format= '%m/%d/%Y', description=u'Game Date(mm/dd/yyyy)')
	home_team = SelectField('Home', [validators.Required(message=(u'Select Team'))],
							choices=[(str(i.id),i.teamname) for i in all_teams],
							description=u'Home Team')
	away_team = SelectField('Away', [validators.Required(message=(u'Select Team'))],
							choices=[(str(i.id),i.teamname) for i in all_teams],
							description=u'Opponent')
	home_score = IntegerField('Home Score', [validators.Optional()],
						 description=u'Home Score')
	away_score = IntegerField('Away Score', [validators.Optional()],
						 description=u'Opponent Score')
示例#12
0
文件: forms.py 项目: ygxing/flaskbbs
class SettingsForm(Form):
    username = TextField(
        u'用户名',
        validators=[Required(),
                    Length(min=4, max=32),
                    Regexp(re_username)])
    #nickname = TextField(u'昵称', validators=[Optional(), Length(max=32)])
    city = TextField(u'城市', validators=[Optional(), Length(max=40)])
    province = TextField(u'省份', validators=[Optional(), Length(max=40)])
    birthday = DateField(u'出生年月日',
                         validators=[Optional()],
                         widget=DatePickerWidget(),
                         default=datetime.date(1990, 1, 1))
    blog = TextField(u'博客', validators=[Optional(), URL(), Length(max=100)])
    descp = TextAreaField(u'个人介绍', validators=[Optional(), Length(max=500)])
    signature = TextAreaField(u'签名', validators=[Optional(), Length(max=200)])
    realname = TextField(u'真实姓名', validators=[Optional(), Length(max=80)])
    idcard = TextField(u'身份证', validators=[Optional(), Length(max=32)])
示例#13
0
文件: forms.py 项目: thuvh/manekineko
class UserForm(Form):
    next = HiddenField()
    role_code = RadioField(u"Role",
                           [AnyOf([str(val) for val in USER_ROLE.keys()])],
                           choices=[(str(val), label)
                                    for val, label in USER_ROLE.items()])
    status_code = RadioField(u"Status",
                             [AnyOf([str(val) for val in USER_STATUS.keys()])],
                             choices=[(str(val), label)
                                      for val, label in USER_STATUS.items()])
    # A demo of datepicker.
    created_time = DateField(u'Created time')
    submit = SubmitField(u'Save')

    def save(self, user):
        self.populate_obj(user)
        db.session.add(user)
        db.session.commit()
示例#14
0
class EditUserForm(Form):
    next = HiddenField()
    role_code = RadioField(_("Role"),
                           [AnyOf([str(val) for val in USER_ROLE.keys()])],
                           choices=[(str(val), label)
                                    for val, label in USER_ROLE.items()])
    status_code = RadioField(_("Status"),
                             [AnyOf([str(val) for val in USER_STATUS.keys()])],
                             choices=[(str(val), label)
                                      for val, label in USER_STATUS.items()])
    # A demo of datepicker.
    vm_quota = IntegerField(
        _("VM Quota"),
        [Required(), NumberRange(VM_QUOTA_MIN, VM_QUOTA_MAX)])
    created_time = DateField(_('Created time'))
    submit = SubmitField(_('Save'))

    def validate_name(self, field):
        if User.query.filter_by(name=field.data).first() is not None:
            raise ValidationError(_(u'This username is taken'))
示例#15
0
class RegisterForm(Form):
	firstname = TextField('First Name', [validators.Required()], 
						  description=u'First Name')
	lastname = TextField('Last Name',[validators.Required()], 
						 description=u'Last Name')
	email = TextField('Email',[validators.Email(message= (u'Invalid email address'))], 
					  description=u'Email')
	password = PasswordField('Password', [validators.Required(), 
							 validators.length(min=6, max=25)],
							 description=u'Password')
	address= TextField('Address',[validators.Required()], 
					   description=u'Address')
	city= TextField('City',[validators.Required()], description=u'City')
	state = TextField('State', [validators.Required(), 
					  validators.length(max=2)], description=u'State')
	zipcode = TextField('Zipcode', [validators.Required()], description=u'Zipcode')
	country = TextField('Country',[validators.Required()], description=u'Country')
	dob = DateField('DOB', [validators.Required(message= (u'Enter birthdate: mm/dd/yyyy'))], 
					format= '%m/%d/%Y', description=u'Date of Birth (mm/dd/yyyy)')
	gender = RadioField('Gender', [validators.Required()], 
						choices=[('male', 'M'),('female','F')], description=u'Gender')
示例#16
0
文件: forms.py 项目: jfx2006/ship-it
class ReleaseForm(Form):
    version = StringField('Version:',
                          validators=[
                              Regexp(ANY_VERSION_REGEX,
                                     message='Invalid version format.')
                          ])
    buildNumber = IntegerField(
        'Build Number:',
        validators=[DataRequired('Build number is required.')])
    branch = StringField('Branch:',
                         validators=[DataRequired('Branch is required')])
    mozillaRevision = StringField('Mozilla Revision:')
    mozillaRelbranch = StringField('Mozilla Relbranch:', filters=[noneFilter])
    comment = TextAreaField('Extra information to release-drivers:')
    description = TextAreaField('Description:')
    isSecurityDriven = BooleanField('Is a security driven release?',
                                    default=False)
    mh_changeset = StringField('Mozharness Revision:')
    release_eta_date = DateField('Release ETA date:',
                                 format='%Y-%m-%d',
                                 validators=[validators.optional()])
    release_eta_time = StringField('Release ETA time:')

    VALID_VERSION_PATTERN = re.compile(
        r"""^(\d+)\.(    # Major version number
        (0)(a1|a2|b(\d+)|esr)?    # 2-digit-versions (like 46.0, 46.0b1, 46.0esr)
        |(  # Here begins the 3-digit-versions.
            ([1-9]\d*)\.(\d+)|(\d+)\.([1-9]\d*) # 46.0.0 is not correct
        )(esr)? # Neither is 46.2.0b1
    )(build(\d+))?$""",
        re.VERBOSE)  # See more examples of (in)valid versions in the tests

    def __init__(self, suggest=True, *args, **kwargs):
        Form.__init__(self, *args, **kwargs)
        if suggest:
            self.addSuggestions()

    def validate(self, *args, **kwargs):
        valid = Form.validate(self, *args, **kwargs)
        # If a relbranch has been passed revision is ignored.
        if self.mozillaRelbranch.data:
            self.mozillaRevision.data = self.mozillaRelbranch.data
        # However, if a relbranch hasn't been passed, revision is required.
        else:
            if not self.mozillaRevision.data:
                valid = False
                self.errors['mozillaRevision'] = [
                    'Mozilla revision is required'
                ]

        if self.VALID_VERSION_PATTERN.match(self.version.data) is None:
            valid = False
            self.errors['version'] = ['Version must match either X.0 or X.Y.Z']

        return valid

    def addSuggestions(self):
        table = getReleaseTable(self.product.data)
        recentReleases = table.getRecent()

        # Before we make any suggestions we need to do some preprocessing of
        # the data to get it into useful structures. Specifically, we need a
        # set containing all of the recent versions, and a dict that associates
        # them with the branch they were built on.
        recentVersions = set()
        recentBranches = defaultdict(list)
        for release in recentReleases:
            recentVersions.add(release.version)
            recentBranches[release.branch].append(MozVersion(release.version))

        # Now that we have the data in the format we want it in we can start
        # making suggestions.
        suggestedVersions = set()
        buildNumbers = {}

        # This wrapper method is used to centralize the build number suggestion
        # logic in one place, because there's more than one spot below that
        # adds a version suggestion.
        def addVersionSuggestion(version):
            suggestedVersions.add(version)
            # We want the UI to be able to automatically set build number
            # to the next available one for whatever version is entered.
            # To make this work we need to tell it what the next available
            # one is for all existing versions. We don't need to add versions
            # that are on build1, because it uses that as the default.
            maxBuildNumber = table.getMaxBuildNumber(version)
            if maxBuildNumber:
                buildNumbers[version] = maxBuildNumber + 1
            else:
                buildNumbers[version] = 1

        # Every version we see will have its potential next versions
        # suggested, except if we already have that version.
        # Note that we don't look through the entire table for every
        # version (because that could be expensive) but any versions
        # which are suggested and have already happened should be in
        # 'recentVersions', so it's unlikely we'll be suggesting
        # something that has already happened.
        for version in recentVersions:
            for v in getPossibleNextVersions(version):
                if v not in recentVersions:
                    addVersionSuggestion(v)

        # Additional, we need to suggest the most recent version for each
        # branch, because we may want a build2 (or higher) of it.
        for branchVersions in recentBranches.values():
            addVersionSuggestion(str(max(branchVersions)))

        # Finally, attach the suggestions to their fields.
        self.branch.suggestions = json.dumps(list(recentBranches.keys()))
        self.version.suggestions = json.dumps(list(suggestedVersions))
        self.buildNumber.suggestions = json.dumps(buildNumbers)

    def updateFromRow(self, row):
        self.version.data = row.version
        self.buildNumber.data = row.buildNumber
        self.branch.data = row.branch
        # Revision is a disabled field if relbranch is present, so we shouldn't
        # put any data in it.
        if not row.mozillaRelbranch:
            self.mozillaRevision.data = row.mozillaRevision
        self.l10nChangesets.data = row.l10nChangesets
        self.mozillaRelbranch.data = row.mozillaRelbranch
        self.mh_changeset.data = row.mh_changeset

        if row.release_eta:
            release_eta = parse_iso8601_to_date_time(row.release_eta)
            self.release_eta_date.data = release_eta.date()
            # Conversion needed because release_eta_time is a StringField
            self.release_eta_time.data = release_eta.strftime('%H:%M %Z')

    @property
    def release_eta(self):
        if self.release_eta_date.data and self.release_eta_time.data:
            dt = self.release_eta_date.data
            tm = datetime.strptime(self.release_eta_time.data,
                                   '%H:%M %Z').time()
            return datetime.combine(dt, tm)
        else:
            return None
示例#17
0
class TempDtlForm(Form):
    act_type = SelectField(u'Transaction Type:',
                           choices=[('upd', 'Update'), ('hir', 'Hire'),
                                    ('xtn', 'Extension'), ('cnv', 'Convert'),
                                    ('ter', 'Terminate')],
                           validators=[validate_empid])
    effdt = DateField('Effective Date:',
                      id='effdt',
                      validators=[Required()],
                      format='%Y-%m-%d')
    first_name = TextField('First Name:',
                           id='first_name',
                           validators=[Required()])
    last_name = TextField('Last Name:',
                          id='last_name',
                          validators=[Required()])
    type = SelectField(u'Temp Type:',
                       choices=[('C', 'Consultant'),
                                ('F', 'Fixed Term Contractors'),
                                ('T', 'Temporary Contractor'),
                                ('W', 'Temporary Worker'), ('O', 'Other')])
    classification = SelectField(u'Classification:',
                                 choices=[('Structural', 'Structural'),
                                          ('Full term', 'Full term'),
                                          ('Project', 'Project'),
                                          ('Interim', 'Interim'),
                                          ('Intermittent', 'Intermittent'),
                                          ('Short Term', 'Short Term')])
    reason = SelectField(u'Action Reason:',
                         choices=[('LOA', 'LOA'), ('Add', 'Add'),
                                  ('Short', 'Short'), ('Seasonal', 'Seasonal'),
                                  ('Project', 'Project'),
                                  ('Replace', 'Replace'), ('Other', 'Other')])
    busn_email = TextField(
        'Work Email:',
        id='email',
        validators=[
            Length(min=6, message=(u'Little short for an email address?')),
            Email(message=(u'That\'s not a valid email address.'))
        ])
    req_num = TextField('Requisition Number:', id='reqnum')
    mgr = TextField('Supervisor:', id='mgr', validators=[Required()])
    supervisor = HiddenField('Supervisor ID:',
                             id='supervisor',
                             validators=[Required()])
    it_end_date = DateField('IT End Date:',
                            id='end_dt',
                            validators=[Required()],
                            format='%Y-%m-%d')
    finance = TextField('Finance Division:',
                        id='finance',
                        validators=[Required()])
    finance_org = TextField('Financial Org:',
                            id='finorg',
                            validators=[Required()])
    hr_contact = HiddenField(id='hr_contact')
    hr_name = TextField('HR Contact:', id='hr_name', validators=[Required()])
    business_title = TextField('Business Title:', id='bus_tit')
    legal_entity = TextField('Legal Entity:',
                             id='legal',
                             validators=[Required()])
    dept = TextField('Department:', id='dept', validators=[Required()])
    location = TextField('Location:', id='location', validators=[Required()])
    remote = BooleanField('Remote:', id='remote')
    busn_phone = TextField('Work Phone:', id='bus_phn')
    vendor_id = TextField('Vendor ID:', id='vndrid')
    it_end_date = DateField('IT End Date:',
                            id='it_end_date',
                            validators=[Required()],
                            format='%Y-%m-%d')
    emplid = HiddenField('Employee ID:', id='emplid')
    action_type = HiddenField(id='action_type')
    id = HiddenField(id='id')
    emplid = TextField('Employee ID:', id='emplid')
    bill_rate = TextField('Bill Rate:', id='brate')
    hourly_rate = TextField('Hourly Rate:', id='hrate')
    comments = TextAreaField('Comments', id='comments')
    mlsnd = BooleanField('Send Mail:', id='mlsnd')
    mailr = QuerySelectMultipleField(query_factory=enabled_categories,
                                     get_label='name',
                                     allow_blank=False)
    submit = SubmitField('Update')
示例#18
0
class person_form(Form):
    first_name = TextField("First name")
    last_name = TextField("Last name")
    birthday = DateField("Birthday",
                         validators=[Optional()],
                         format="%m/%d/%Y")
示例#19
0
class CreateArchiveForm(Form):
    name = TextField(_("Name for this archive (optional)"), validators=[])
    start_date = DateField(_("Start date"), validators=[Required()])
    end_date = DateField(_("End date"), validators=[Required()], default=datetime.now)
示例#20
0
class edit_series(Form):
    title = TextField("Series title")
    begin_date = DateField("Begin date", validators=[Optional()], format='%m/%d/%Y')
    end_date = DateField("End date", validators=[Optional()], format='%m/%d/%Y')
示例#21
0
class ListUsersForm(ExtForm):
    date = DateField(default=lambda: datetime.now().date())
    status = IntegerField()
示例#22
0
class ProfileForm(Form):
    first_name = TextField(
        label=_('First Name'),
        validators=[
            Length(
                min=FIRSTNAME_LEN_MIN,
                max=FIRSTNAME_LEN_MAX,
                ),
            ],
        )
    last_name = TextField(
        label=_('Last Name'),
        validators=[
            Length(
                min=LASTNAME_LEN_MIN,
                max=LASTNAME_LEN_MAX,
                ),
            ],
        )
    username = TextField(
        label=_('Username'),
        validators=[
            Required(),
            Length(
                min=USERNAME_LEN_MIN,
                max=USERNAME_LEN_MAX,
                ),
            ],
        description=_(u"Combination of letters/digits/underscore, at least %s characters." % USERNAME_LEN_MIN),
        )
    email = EmailField(
        label=_('Email'),
        validators=[Email(
            message=_("Doesn't look like a valid email.")
            )],
        )
    """ TODO role_id = RadioField(
        label=_('Role'),
        validators=[
            validators.AnyOf(USER_ROLE.keys())
            ],
        choices=USER_ROLE.items(),
        )"""
    gender = SelectField(
        label=_('Gender'),
        choices=[
            ('male', 'Male'),
            ('female', 'Female')
            ]
        )
    dob = DateField(
        label=_('Date of Birth')
        )
    phone = TelField(
        label=_('Phone Number'),
        )
    bio = TextAreaField(
        label=_('Biography'),
        validators=[
            Length(
                max=1024,
                ),
            ]
        )
    url = URLField(
        label=_('Website'),
        validators=[
            URL(),
            ],
        )
    submit = SubmitField(_('Save'))
示例#23
0
class DateForm(Form):
    date = DateField(u'Date', format='%Y-%m-%d')