class PrinterConfigurationForm(Form):
    name = TextField("Name", validators=[Required()])
    configuration = TextField("Configuration Name", validators=[Required()])
    description = TextAreaField("Description", validators=[Required()])
示例#2
0
class CommentsForm(Form):
    contents = TextAreaField(u'Comments', validators=[Required()])
示例#3
0
文件: account.py 项目: cash2one/cn486
class PeopleEditForm(Form):
    """
    编辑 账户 的表单
    """

    nickname = TextField(_("user.nickname"),
                         description=u'昵称',
                         validators=[
                             required(message=_("nickname is required")),
                             length(min=2,
                                    max=20,
                                    message=_("Length range: 2 - 20"))
                         ])

    homepage = TextField(_("user.homepage"),
                         description=u'个人主页',
                         validators=[
                             url(message=_("homepage is not a valid URL")),
                             length(min=0,
                                    max=50,
                                    message=_("Length range: 11 - 50"))
                         ])

    avatar = TextField(
        _("user.avatar"),
        description=u'头像',
        validators=[
            #url(message=_("avatar is not a valid URL")),
            length(min=0, max=50, message=_("Length range: 11 - 50"))
        ])

    gender = SelectField(_("user.gender"),
                         description=u'性别:0-保密、1-男、2-女',
                         choices=[('0', u'保密'), ('1', u'男'), ('2', u'女')],
                         validators=[
                             required(message=_("gender is required")),
                         ])

    bio = TextAreaField(_("user.bio"),
                        description=u'自我介绍',
                        validators=[
                            length(min=0,
                                   max=200,
                                   message=_("Length range: 1 - 200"))
                        ])

    interest = TextAreaField(_("user.interest"),
                             description=u'研究领域/兴趣范围(多个用,分开)',
                             validators=[])

    def validate_nickname(self, field):
        # todo
        #        # 昵称不允许重复
        #        if not UserService.count_by_nickname(field.data):
        #            raise ValidationError, gettext("This nickname is taken")
        if not WordReservedService.word_allowed(field.data):
            raise ValidationError, gettext("This nickname is taken")

    id = HiddenField()

    next = HiddenField()

    submit = SubmitField(_("Submit"))
示例#4
0
class MyForm(Form):
    name = TextField("name", validators=[Required()])
    text = TextAreaField("txt")
    submit = SubmitField("Share")
示例#5
0
class EditorForm(Form):
    title = TextField('', [Required()])
    body = TextAreaField('', [Required()])
    tags = TextField('')
示例#6
0
文件: app.py 项目: techniq/flask-wtf
class CommentForm(Form):

    comment = TextAreaField("Comment", validators=[Required()])
    recaptcha = RecaptchaField()
示例#7
0
class EntryForm(Form):

    title = TextField("Title", validators=[Required()])
    text = TextAreaField("Text")
    submit = SubmitField("Share")
示例#8
0
class CommentAbuseForm(Form):
    complaint = TextAreaField("抱怨", validators=[required(message="你有些啥抱怨呢?")])
    submit = SubmitField(u"提交")
示例#9
0
class ADForm(Form):
    name = TextField(u'名称',[Required(u'请输入名称')])
    product = QuerySelectField(u'产品',query_factory=lambda :AD_Product.query.all(), get_label='name')
    place = QuerySelectField(u'媒体广告位',query_factory=lambda :AD_Place.query.order_by(AD_Place.medium_id), get_label='fullname')
    content = QuerySelectField(u'展示内容',query_factory=lambda :AD_Content.query.all(), get_label='fullname')
    remark = TextAreaField(u'备注',[Optional()])
示例#10
0
class ExampleForm(Form):
    title = TextField(u'Title', validators=[Required()])
    content = TextAreaField(u'Content')
    date = DateTimeField(u'Data', format='%d/%m/%Y %H:%M')
示例#11
0
class ReplyForm(Form):
    content = TextAreaField(u"回复",
                            validators=[Required()],
                            description=u"支持Markdown语言")
示例#12
0
class GroupForm(Form):
    id = TextField("Group name",
                   validators=[Required(), Length(min=1, max=16)])
    description = TextAreaField("Description")
示例#13
0
文件: forms.py 项目: abits/seotool
class ReportConfigurationForm(Form):
    summary = TextAreaField('Summary', validators=[Length(max=4096)])
    charts = FormField(ChartConfigurationForm)
示例#14
0
文件: topic.py 项目: znetor/june
class ReplyForm(BaseForm):
    content = TextAreaField(_('Content'), validators=[DataRequired()])

    def save(self, user, topic):
        item = Reply(**self.data)
        return item.save(user=user, topic=topic)
示例#15
0
class AddQuestionForm(Form):

    description = TextAreaField(_(u"问题描述"))

    submit = SubmitField(_(u"提交"))
示例#16
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'))
示例#17
0
class NewsCreateForm(Form):
    title = TextField('Title', [Required()])
    text = TextAreaField('Text', [Required()])
示例#18
0
class EditBlogPostForm(Form):
    next = HiddenField()
    headline = TextField(u'Headline', [Required()])
    tags = SelectMultipleField(u'Tags', coerce=int)
    body = TextAreaField(u'Content', [Required(), Length(0, 10000)])
    submit = SubmitField('Save')
示例#19
0
文件: result.py 项目: isuker/snippets
class CommentForm(Form):
    comment = TextAreaField(validators=[required(message="内容不能为空")])
    submit = SubmitField(u"提交")
    cancel = SubmitField(u"取消")
示例#20
0
class CreateBlogPostForm(Form):
    next = HiddenField()
    headline = TextField(u'Headline', [Required()])
    body = TextAreaField(u'Content', [Required(), Length(0, 10000)])
    submit = SubmitField('Create')
示例#21
0
class PostForm(Form):
    post = TextAreaField('Post', [validators.Required(), 
    				  validators.length(min=0, max=140)],
    				  description=u'Wanna say something?!')
示例#22
0
class ContactForm(Form):
  name = TextField("Name", [validators.Required("Please enter your name")])
  email = TextField("Email", [validators.Required("Please enter a valid email address"), validators.Email()])
  subject = TextField("Subject", [validators.Required("Please enter a subject")])
  message = TextAreaField("Message", [validators.Required("Please enter a message")])
  submit = SubmitField("Send")
示例#23
0
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
示例#24
0
class ConversationForm(Form):
    subject = TextField('subject')
    content = TextAreaField('content', [Required()])
示例#25
0
class TopicForm(Form):
    title = TextField(u'Title', validators=[Required()])
    contents = TextAreaField(u'Contents')
示例#26
0
class BlogPostForm(Form):
    title = TextField(u'Title', validators=[Required()])
    body = TextAreaField(u'Content')
    date = DateTimeField(u'Date', format='%Y-%m-%d')
    author = TextField(u'Author', validators=[Required()])
示例#27
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')
示例#28
0
文件: forms.py 项目: huchenme/flitter
class PostForm(Form):
    post = TextAreaField('Say something...', [Required(), Length(max=200)])
    submit = SubmitField('Post!')
示例#29
0
class Contacts(Form):
    name = TextField("Name")
    email = TextField("Email")
    subject = TextField("Subject")
    message = TextAreaField("Message")
    submit = SubmitField("Send The Message")
示例#30
0
class NewsForm(Form):
    title = TextField(u'标题', [Required(u'标题不可为空')])
    content = TextAreaField('内容')