class PermissionForm(Form): endpoint = TextField(u'Endpoint') module_text = TextField(u'模块显示名') name = TextField(u'子模块显示名') operation = TextField(u'操作名') default_permission = SelectField(u'有效性', [required(message=u'必填')], choices=[(u'0', u'无权限'), (u'1', u'有权限')]) next = HiddenField()
class NextFormMixin(): next = HiddenField() def validate_next(self, field): url_next = urlparse.urlsplit(field.data) url_base = urlparse.urlsplit(request.host_url) if url_next.netloc and url_next.netloc != url_base.netloc: field.data = '' raise ValidationError(get_message('INVALID_REDIRECT')[0])
class AlarmClassForm(Form): id = HiddenField(u'Id') severity = SelectFieldPro(u'级别', validators=[required(message=u'必填')], choices=lambda: [(unicode(r.id), r.alias) for r in AlarmSeverity.query]) #x733_type = tables.Column(verbose_name=u'X733类型') probable_cause = TextAreaField(u'可能原因') specific_problem = TextAreaField(u'特定原因') additional_info = TextAreaField(u'附加信息') remark = TextAreaField(u'备注')
class LoginForm(Form, EmailFormMixin, PasswordFormMixin): " The default login form. " remember = BooleanField(_("Remember Me"), default=True) next = HiddenField() submit = SubmitField(_("Login")) def __init__(self, *args, **kwargs): super(LoginForm, self).__init__(*args, **kwargs) if request.method == 'GET': self.next.data = request.args.get('next', None)
class StatForm(Form): stat = HiddenField('stat_select', id='stat_select', validators=[Required()]) benchmarks = SelectMultipleField('benchmark_select', id='benchmark_select', validators=[Required()]) runs = SelectMultipleField('run_select', id='run_select', validators=[Required()], coerce=str) normalize = BooleanField('normalize', id='normalize', validators=[Required()]) average = BooleanField('average', id='average', validators=[Required()]) hmean = BooleanField('hmean', id='hmean', validators=[Required()]) submit = SubmitField('Update', id='Update')
class BookmarkForm(AjaxForm): id = HiddenField(u'Id') link = URLField(u'Link', validators=[ validators.required(), validators.url(), ]) title = TextField(u'Title', validators=[ validators.required(), ]) description = TextAreaField(u'Description') tags = TextField(u'Tags') submit = SubmitField(u'Add') edit = SubmitField(u'Edit') def __init__(self, formdata=None, *args, **kwargs): self.id.data = kwargs.get('id', None) super(BookmarkForm, self).__init__(formdata, *args, **kwargs) def validate(self): rv = Form.validate(self) if not rv: return False _id = self.id.data link = self.link.data title = self.title.data description = self.description.data tags = map(lambda x: {'name': x.strip()}, self.tags.data.split(',')) if _id is None or _id == '' or int(_id) < 1: self.bookmark = ItemBookmark(tags=tags, link=link, title=title, description=description) else: self.bookmark = get_bookmark_by_id(_id) if self.bookmark is None: abort(404) self.bookmark.title = title self.bookmark.description = description self.bookmark.set_tags(tags) return True
class ResetPasswordForm(Form, EmailFormMixin, PasswordFormMixin, PasswordConfirmFormMixin): " The default reset password form. " token = HiddenField(validators=[Required()]) submit = SubmitField(_("Reset Password")) def __init__(self, *args, **kwargs): super(ResetPasswordForm, self).__init__(*args, **kwargs) if request.method == 'GET': self.token.data = request.args.get('token', None) self.email.data = request.args.get('email', None) def to_dict(self): return dict(token=self.token.data, email=self.email.data, password=self.password.data)
def add_csrf(): self._csrf_token = HiddenField(default=g._csrf_token)
class QueryNewForm(Form): tab = HiddenField() name = TextField(u'名称', validators=[required(message=u'必填')]) is_public = BooleanField()
class LoginForm(Form): username = TextField(u'用户名') password = PasswordField(u'密码') next = HiddenField() remember = BooleanField(u'记住我')