コード例 #1
0
ファイル: payment.py プロジェクト: huntergps/nanoinvoice
class PaymentForm(Form):
    """Form for a new custom field"""

    DATE_FORMAT = '%a %b %d %Y'

    invoice_id = HiddenField()
    amount = TextField('Amount', [required()])
    description = TextField()
    date = TextField('Date', [required()])

    def __init__(self, formdata=None, obj=None, prefix='', **kwargs):
        super(PaymentForm, self).__init__(formdata, obj, prefix, **kwargs)
        if obj is not None:
            self.payment = obj
        else:
            self.payment = None

    def save(self):
        """Save the payment model"""
        self.payment.amount = self.amount.data
        self.payment.date = datetime.strptime(self.date.data, self.DATE_FORMAT)
        self.payment.description = self.description.data

        db.session.add(self.payment)
        db.session.commit()

        self.payment.invoice.update_payment_status()

        return self.payment
コード例 #2
0
class SapplyForm(Form):
    name = TextField(u'简述', validators=[required(), length(max=64)])
    s_id = SelectField(u'机器型号', coerce=int, validators=[required()])
    s_num = TextField(u'数量', validators=[required(), regexp(u'^[0-9]+$'), length(max=11)])
    status = TextField(u'状态', validators=[])
    days = TextField(u'天数', validators=[regexp(u'^[0-9]*$')])
    desc = TextAreaField(u'描述', validators=[])
コード例 #3
0
ファイル: frontend.py プロジェクト: huntergps/nanoinvoice
class LoginForm(Form):
    next = HiddenField()
    remember = BooleanField(_('Remember me'))
    login = TextField(_('Username or email address'), [required()])
    password = PasswordField(_('Password'),
                             [required(), length(min=6, max=16)])
    submit = SubmitField(_('Login'))
コード例 #4
0
ファイル: account.py プロジェクト: yxm0513/7topdig
class LoginForm(Form):
    next = HiddenField()
    remember = BooleanField(u"在这台电脑记住我")
    login = TextField(u"账号:", validators=[ required(message=\
                               u"你必须提供一个用户名或是 Email")])
    password = PasswordField(u"密码:", [required()])
    submit = SubmitField(u"登录")
コード例 #5
0
class EditCodeForm(Form):
    '''It is used for editing codes, defines edit codes form.'''

    next = HiddenField()
    name = TextField(_(u"名称:"),
                     validators=[required(_(u"请输入名称")), is_legal_name])

    description = TextAreaField(_(u"描述:"))

    related_module = SelectField(_(u"所属模块:"), default=0, coerce=int)

    path = FileField(u"代码文件", validators=[required(message=_(u"请选择文件"))])

    submit = SubmitField(_(u"保存"))

    def __init__(self, code, *args, **kwargs):
        self.code = code
        kwargs['obj'] = self.code
        super(EditCodeForm, self).__init__(*args, **kwargs)

    def validate_name(self, field):
        code = Code.query.filter(
            db.and_(Code.name.like(field.data),
                    db.not_(Code.id == self.code.id))).first()
        if code:
            raise ValidationError(gettext(u"名称已经存在"))
コード例 #6
0
ファイル: openid.py プロジェクト: lypinggan/newsmeme
class OpenIdSignupForm(Form):

    next = HiddenField()

    username = TextField(
        _("Username"),
        validators=[required(_("Username required")), is_username])

    email = TextField(_("Email address"),
                      validators=[
                          required(message=_("Email address required")),
                          email(message=_("Valid email address required"))
                      ])

    recaptcha = RecaptchaField(_("Copy the words appearing below"))

    submit = SubmitField(_("Signup"))

    def validate_username(self, field):
        user = User.query.filter(User.username.like(field.data)).first()
        if user:
            raise ValidationError, gettext("This username is taken")

    def validate_email(self, field):
        user = User.query.filter(User.email.like(field.data)).first()
        if user:
            raise ValidationError, gettext("This email is taken")
コード例 #7
0
ファイル: forms.py プロジェクト: lpfan/Wing-M.S.
class LoginForm(wtf.Form):
    login = wtf.TextField(
        label=u"Ім`я",
        validators=[wtf.required()]
    )

    password = wtf.PasswordField(
        label=u"Пароль",
        validators=[wtf.required()]
    )

    def validate_login(self, field):
        user = self.get_user()

        if user is None:
            raise wtf.ValidationError(u'Користувача з логіном %s не існує' % self.login.data)

        if not user.is_authenticated(aUser=''.join(self.login.raw_data), aPassword=''.join(self.password.raw_data)):
            raise wtf.ValidationError(u'Неспівпадіння паролей')

    def get_user(self):
    	user = None
        try:
            user = User.get(login=self.login.raw_data)
        except User.DoesNotExist, e:
            print 'User with %s username does not exists' % self.login.raw_data
        return user
コード例 #8
0
class SignupForm(Form):
    '''It is used for sign up, defines sign up form.'''

    next = HiddenField()

    username = TextField(_(u"用户名:"), validators=[
                         required(message=_(u"请输入用户名或者邮箱地址")),
                         is_legal_name])

    password = PasswordField(_(u"密码:"), validators=[
                             required(message=_(u"请输入密码"))])

    password_again = PasswordField(_(u"确认密码:"), validators=[
                                   equal_to(u"password", message=
                                            _(u"密码不一致"))])

    email = TextField(_(u"邮箱地址:"), validators=[
                      required(message=_(u"请输入邮箱地址")),
                      email(message=_(u"请输入有效的邮箱地址"))])

    submit = SubmitField(_(u"注册"))

    def validate_username(self, field):
        user = User.query.filter(User.username.like(field.data)).first()
        if user:
            raise ValidationError(gettext(u"用户名已经存在"))

    def validate_email(self, field):
        user = User.query.filter(User.email.like(field.data)).first()
        if user:
            raise ValidationError(gettext(u"邮箱地址已经存在"))
コード例 #9
0
ファイル: account.py プロジェクト: cash2one/cn486
class LoginForm(Form):
    """
    登录表单
    """
    login = TextField(_("Email address"),
                      validators=[
                          required(message=_("You must provide an email")),
                          email(message=_("A valid email address is required"))
                      ])

    password = PasswordField(
        _("Password"),
        validators=[required(message=_("You must provide an password"))])

    recaptcha = TextField(
        _("Recaptcha"),
        validators=[])  # required(message=_("You must provide an captcha"))

    remember = BooleanField(_("Remember me"))

    next = HiddenField()

    def validate_recaptcha(self, field):
        if 'need_verify' not in session or not session['need_verify']:
            return

        if 'verify' not in session or session['verify'] != str(
                field.data).upper():
            raise ValidationError, gettext("This captcha is not matching")

    submit = SubmitField(_("Login"))
コード例 #10
0
ファイル: user.py プロジェクト: huntergps/nanoinvoice
class UserForm(Form):
    first_name = TextField(u'First name', validators=[required()])
    last_name = TextField(u'Last name', validators=[required()])
    email_address = TextField(u'Email address',
                              validators=[required(), Email()])
    password = PasswordField(
        u'New password', validators=[Optional(),
                                     EqualTo('password_confirm')])
    password_confirm = PasswordField(u'Password confirm',
                                     validators=[Optional()])

    def __init__(self, formdata=None, obj=None, prefix='', **kwargs):
        super(UserForm, self).__init__(formdata, obj, prefix, **kwargs)
        if obj:
            self.user = obj
        else:
            self.user = None

    def validate_email_address(self, field):
        user = User.query.filter_by(email_address=field.data) \
                         .filter(User.id != self.user.id).first()
        if user:
            raise ValidationError('That email address is already in use')

    def save(self):
        self.user.first_name = self.first_name.data
        self.user.last_name = self.last_name.data
        self.user.email_address = self.email_address.data

        if len(self.password.data) > 1:
            self.user.password = self.password.data

        db.session.add(self.user)
        db.session.commit()
        return self.user
コード例 #11
0
class EditMyAccountForm(Form):

    username = TextField(_(u"用户名:"), validators=[
                         required(_(u"请输入用户名")), is_legal_name])

    email = TextField(_(u"邮箱地址:"), validators=[
                      required(message=_(u"请输入邮箱地址")),
                      email(message=_(u"请输入有效的邮箱地址"))])

    email_alerts = BooleanField(_(u"开启邮件提醒"))

    status = BooleanField(_(u"账号状态"))

    submit = SubmitField(_(u"保存"))

    def __init__(self, user, *args, **kwargs):
        self.user = user
        kwargs['obj'] = self.user
        super(EditMyAccountForm, self).__init__(*args, **kwargs)

    def validate_username(self, field):
        user = User.query.filter(db.and_(
                                 User.username.like(field.data),
                                 db.not_(User.id == self.user.id))).first()

        if user:
            raise ValidationError(gettext(u"用户名已经存在"))

    def validate_email(self, field):
        user = User.query.filter(db.and_(
                                 User.email.like(field.data),
                                 db.not_(User.id == self.user.id))).first()
        if user:
            raise ValidationError(gettext(u"邮箱地址已经存在"))
コード例 #12
0
ファイル: account.py プロジェクト: isuker/snippets
class LoginForm(Form):
    next = HiddenField()
    remember = BooleanField("Remember me in this computer")
    login = TextField("Account: ", validators=[ required(message=\
                               "you must input valid username")])
    password = PasswordField("Password: "******"Login")
コード例 #13
0
class LoginForm(Form):
    """
    登錄用的表單
    """
    account = TextField(u"帳號", validators=[required()])
    password = PasswordField(u"密碼", validators=[required()])
    submit = SubmitField(u"登入")
コード例 #14
0
class SignupForm(Form):

    next = HiddenField()

    username = TextField(
        u"用户名",
        validators=[required(message=_("Username required")), is_username])

    password = PasswordField(
        u"密码", validators=[required(message=_("Password required"))])

    password_again = PasswordField(u"密码确认", validators=[
                                   equal_to("password", message=\
                                            _("Passwords don't match"))])

    email = TextField(u"邮箱",
                      validators=[
                          required(message=_("Email address required")),
                          email(message=_("A valid email address is required"))
                      ])

    recaptcha = RecaptchaField(_("Copy the words appearing below"))

    submit = SubmitField(u"注册")

    def validate_username(self, field):
        user = User.query.filter(User.username.like(field.data)).first()
        if user:
            raise ValidationError, u"改用户名已存在"

    def validate_email(self, field):
        user = User.query.filter(User.email.like(field.data)).first()
        if user:
            raise ValidationError, gettext("This email is taken")
コード例 #15
0
class EditMachineForm(Form):
    name = TextField(_(u"机器名:"),
                     validators=[required(_(u"请输入机器名")), is_legal_name])
    description = TextAreaField(_(u"描述:"))
    status = RadioField(_(u"状态:"),
                        default=Machine.OK,
                        coerce=int,
                        choices=((Machine.OK, _(u"正常")), (Machine.REALLY,
                                                          _(u"停用"))))
    username = TextField(_(u"用户名:"), validators=[required(_(u"请输入用户名"))])
    password = TextField(_(u"密码:"), validators=[required(message=_(u"请输入密码"))])
    url_hudson = TextField(_(u"Hudson地址:"),
                           validators=[required(_(u"请输入Hudson地址"))])
    key = TextField(_(u"SSH Key:"))
    submit = SubmitField(_(u"保存"))

    def __init__(self, machine, *args, **kwargs):
        self.machine = machine
        kwargs['obj'] = self.machine
        super(EditMachineForm, self).__init__(*args, **kwargs)

    def validate_name(self, field):
        machine = Machine.query.filter(
            db.and_(Machine.name.like(field.data),
                    db.not_(Machine.id == self.machine.id))).first()
        if machine:
            raise ValidationError(gettext(u"机器名已经存在"))
コード例 #16
0
class SignupForm(Form):
    next = HiddenField()
    name = TextField(_('Username'), [required()])
    password = PasswordField(
        _('Password'),
        [required(), length(min=PASSLEN_MIN, max=PASSLEN_MAX)])
    password_again = PasswordField(_('Password again'), [
        required(),
        length(min=PASSLEN_MIN, max=PASSLEN_MAX),
        equal_to('password')
    ])
    email = TextField(
        _('Email address'),
        [required(),
         email(message=_('A valid email address is required'))])
    invitation_code = TextField(
        _('Invitation Code'),
        [required(message=_('Please fill in the invitation code!'))])
    submit = SubmitField(_('Signup'))

    def validate_name(self, field):
        if g.db.users.find_one({"_id": field.data}) is not None:
            raise ValidationError, _('This username is taken')

    def validate_email(self, field):
        if g.db.users.find_one({"email": field.data}) is not None:
            raise ValidationError, _('This email is taken')

    def validate_invitation_code(self, field):
        if g.db.invitates.find_one({
                "code": field.data,
                "used": 'False'
        }) is None:
            raise ValidationError, _('Invalid code')
コード例 #17
0
class CustomerForm(wtf.Form):
    address = wtf.TextField(u'收获地址', validators=[wtf.required()])
    phone = wtf.TextField(u'联系电话', validators=[wtf.required()])

    def validate_login(self, field):
        if not login.current_user.is_authenticated():
            raise wtf.ValidationError('Not login')
コード例 #18
0
class RegisterForm(Form):
    """
    註冊用的表單
    """
    account = TextField(u"帳號", validators=[required()])
    password = PasswordField(u"密碼", validators=[required()])
    repassword = PasswordField(u"確認密碼", validators=[required()])
    submit = SubmitField(u"註冊")
コード例 #19
0
ファイル: gamebase.py プロジェクト: hw233/twisted_zdzl
class RoleLevelForm(BaseAjaxForm):
    level = TextField(u'等级', validators=[required(message=u'请输入等级')])
    exp = TextField(u'经验', validators=[required(message=u'请输入经验')])
    siteExp = TextField(u'打坐经验', validators=[required(message=u'打坐经难')])

    def validate_level(self, field):
        if field.data == '':
            raise ValidationError, u"等级不能为空。"
コード例 #20
0
ファイル: auth.py プロジェクト: tmgames-nl/flask-admin
class RegistrationForm(wtf.Form):
    login = wtf.TextField(validators=[wtf.required()])
    email = wtf.TextField()
    password = wtf.PasswordField(validators=[wtf.required()])

    def validate_login(self, field):
        if User.objects(login=self.login.data):
            raise wtf.ValidationError('Duplicate username')
コード例 #21
0
ファイル: user.py プロジェクト: yxm0513/7topdig
class MessageForm(Form):
    subject = TextField(u"标题", validators=[
                        required(message=u"需要有标题")])

    message = TextAreaField(u"内容", validators=[
                            required(message=u"需要有内容")])

    submit = SubmitField(u"发送")
コード例 #22
0
class RegistrationForm(wtf.Form):
    login = wtf.TextField(u'用户名', validators=[wtf.required()])
    email = wtf.TextField(u'邮箱')
    password = wtf.PasswordField(u'密码', validators=[wtf.required()])

    def validate_login(self, field):
        if db.session.query(User).filter_by(login=self.login.data).count() > 0:
            raise wtf.ValidationError('Duplicate username')
コード例 #23
0
class LoginForm(Form):

    next = HiddenField()
    remember = BooleanField()
    email = TextField(
        validators=[required(message=u'邮箱是必须的'),
                    email(message=u'你的邮箱不合法')])
    password = PasswordField(validators=[required(message=u'密码没有填写')])
    submit = SubmitField()
コード例 #24
0
ファイル: user.py プロジェクト: isuker/snippets
class ContactForm(Form):
    name = TextField(u"你的姓名", validators=[required(message=u'姓名是必须的')])
    email = TextField(
        u"你的邮件",
        validators=[required(message=u"邮件是必须的"),
                    email(message=u"需要是有效的邮箱地址")])
    subject = TextField(u"标题", validators=[required(message=u"需要有标题")])
    message = TextAreaField(u"内容", validators=[required(message=u"内容是必须的")])
    submit = SubmitField(u"发送")
コード例 #25
0
ファイル: contact.py プロジェクト: lypinggan/newsmeme
class MessageForm(Form):

    subject = TextField(_("Subject"),
                        validators=[required(message=_("Subject required"))])

    message = TextAreaField(
        _("Message"), validators=[required(message=_("Message required"))])

    submit = SubmitField(_("Send"))
コード例 #26
0
class LoginForm(Form):

    username = TextField("Username",
                         validators=[required(message="Username required")])

    password = PasswordField(
        "Password", validators=[required(message="Password required")])

    remember = BooleanField("Remember?")
コード例 #27
0
ファイル: forms.py プロジェクト: lpfan/Wing-M.S.
class RegistrationForm(wtf.Form):
    login = wtf.TextField(validators=[wtf.required()])
    email = wtf.TextField(validators=[wtf.required(), wtf.validators.Email()])
    password = wtf.PasswordField(validators=[wtf.required()])

    def validate_login(self, field):
        current_ident_hash = bcrypt.generate_password_hash("".join(self.login.raw_data))
        if User.filter(ident_hash=current_ident_hash).count():
            raise wtf.ValidationError(u'Користувач з ніком %s вже зареєстрований. Оберіть інше ім`я')
コード例 #28
0
class CategoriesView(AuthenticatedView, ModelView):

    column_list = ('name', 'slug')
    form_columns = ('name', 'slug', 'description', 'position')
    form_overrides = dict(description=wtf.TextAreaField)
    form_args = dict(name=dict(validators=[wtf.required()]),
                     slug=dict(validators=[wtf.required()]))

    def __init__(self, session, **kwargs):
        super(CategoriesView, self).__init__(Category, session, **kwargs)
コード例 #29
0
ファイル: forms.py プロジェクト: yahos/flaskblog-blueprints
class CommentForm(Form):
    author_name = TextField(u'Name', validators=[required(message=u"Need an name"), length(max=50)])
    author_email = TextField(u"Email", validators=[
                             required(message=u"Need an email address"),
                             email(message=u"Need a valid email address")])
    author_url = TextField(u"Url")
    content = TextAreaField(u"Content")
    post_id = TextField()
    #recaptcha = RecaptchaField(u"Copy the words appearing below")
    submit = SubmitField(u"Save")
コード例 #30
0
ファイル: forms.py プロジェクト: lpfan/Wing-M.S.
class MetaDataForm(wtf.Form):
    meta_d = wtf.TextAreaField(
        label=u'"Пошуковий" опис',
        description=u"Пошукові системи відображають цю інформацію при виводі результатів пошуку",
        validators=[wtf.required()]
    )
    meta_k = wtf.TextAreaField(
        label=u"Ключові слова",
        description=u"Перелік ключових слів, які будуть застосовуватися на кожній сторінці сайту",
        validators=[wtf.required()]
    )