Ejemplo n.º 1
0
class ConnectionForm(Form):
    # les 2 champs sont obligatoires
    email = StringField(
        'Adresse courriel',
        [validators.data_required(message='Ce champ doit etre remplis')])
    password = PasswordField(
        'Mot de passe',
        [validators.data_required(message='Ce champ doit etre remplis')])
Ejemplo n.º 2
0
class Login(FlaskForm):
    usu = StringField(
        'Usuario',
        [validators.data_required(message="Debe ingresar un usuario")])
    passw = PasswordField(
        'Login',
        [validators.data_required(message="Debe ingresar una contrasena")])
    submit = SubmitField("Ingresar")
Ejemplo n.º 3
0
class CommentForm(Form):
    content = StringField(u'내용',
                          [validators.data_required(u'내용을 입력하시기 바랍니다.')],
                          description={'placeholder': u'내용을 입력하세요.'})
    password = PasswordField(u'비밀번호',
                             [validators.data_required(u'비밀번호를 입력하시기 바랍니다.')],
                             description={'placeholder': u'비밀번호를 입력하세요.'})
    email = EmailField(u'이메일', [validators.data_required(u'이메일을 입력하시기 바랍니다.')],
                       description={'placeholder': u'이메일을 입력하세요.'})
Ejemplo n.º 4
0
class ArticleForm(Form):
    title = StringField(u'제목', [validators.data_required(u'제목을 입력하시기 바랍니다.')],
                        description={'placeholder': u'제목을 입력하세요.'})
    content = TextAreaField(u'내용',
                            [validators.data_required(u'내용을 입력하시기 바랍니다.')],
                            description={'placeholder': u'내용을 입력하세요.'})
    category = StringField(u'카테고리',
                           [validators.data_required(u'카테고리를 입력하시기 바랍니다.')],
                           description={'placeholder': u'카테고리를 입력하세요.'})
Ejemplo n.º 5
0
class passwdResetConfirm(Form):
    password = PasswordField(u'비밀번호', [
        validators.data_required(u'새로운 비밀번호를 입력해주세요.'),
        validators.EqualTo('confirm_password', message=u'비밀번호가 일치하지 않습니다!')
    ],
                             description={'placeholder': u'새로운 비밀번호!'})
    confirm_password = PasswordField(
        u'비밀번호 확인', [validators.data_required(u'비밀번를 한번 더 입력하세요.')],
        description={'placeholder': u'비밀번호 한번 더!'})
Ejemplo n.º 6
0
class UserLoginForm(Form):
    username = StringField(
        'username',
        [validators.data_required(),
         validators.Length(min=4, max=25)])
    password = PasswordField(
        'password',
        [validators.data_required(),
         validators.Length(min=6, max=200)])
Ejemplo n.º 7
0
class RegistrationForm(FlaskForm):
    username = StringField('Username',
                           validators=[
                               data_required(), length(min=2, max=20)])
    email = StringField('Email', validators=[data_required(), email()])
    password = PasswordField('Password', validators=[data_required()])
    confirm_password = PasswordField(
        'Password', validators=[data_required(), equal_to('password')])
    submit = SubmitField('Sign Up')
Ejemplo n.º 8
0
class RegisterForm(Form):
    name=StringField("İsim Soyisim",validators=[validators.Length(min=4, max=25),validators.data_required()])
    username=StringField("Kullanıcı Adı",validators=[validators.Length(min=5, max=35),validators.data_required()])
    email=StringField("E-Posta",validators=[validators.data_required(),validators.email(message="Lütfen Geçerli Bir E-Posta Adresi Girin.")])
    password=PasswordField("Parola", validators=[
        validators.data_required(message="Lütfen Parola Girin"),
        validators.EqualTo(fieldname="confirm",message="Parolalar uyuşmuyor")
    ])
    confirm=PasswordField("Parola Tekrar")
Ejemplo n.º 9
0
class RequestsForm(Form):

    building = StringField("Building: ",
                           [validators.data_required("Please, enter login.")])
    audience = IntegerField(
        "Audience: ",
        [validators.data_required("Please, enter year of enrollment.")])

    submit = SubmitField("Enter")
Ejemplo n.º 10
0
class NewVideoForm(Form):
    name = StringField(
        'Title',
        [validators.data_required(),
         validators.Length(min=1, max=100)])
    url = StringField(
        'iframe',
        [validators.data_required(),
         validators.Length(min=1, max=500)])
Ejemplo n.º 11
0
class LoginForm(FlaskForm):
    username = StringField('用户名: ', validators=[data_required()])
    password = PasswordField('密码: ', validators=[data_required()])
    password2 = PasswordField(
        '确认密码: ',
        validators=[data_required(),
                    equal_to('password', message='密码不一致')])

    submit = SubmitField('提交')
Ejemplo n.º 12
0
class NameForm(FlaskForm):
    # 网页表格
    name = StringField('What is your name?', validators=[data_required()])
    accept_tos = BooleanField(
        'I accept the TOS',
        validators=[
            data_required()],
        default='checked')
    submit = SubmitField('Submit')
class PendingRequestsForm(Form):
    decision = RadioField('Admin Decision',
                          choices=[('approve', 'Approve'), ('deny', 'Deny')],
                          validators=[validators.data_required()])
    comment = StringField('Comment')
    person = HiddenField()
    team = SelectField('Team',
                       validators=[validators.data_required()],
                       choices=admin_team_choices)
Ejemplo n.º 14
0
class PermissionsForm(Form):
    title = StringField('权限名',validators=[data_required("权限名不能为空"),length(min=3,max=128,message="长度在3到32位字符")])
    url = StringField('地址',validators=[data_required("地址不能为空"),length(min=1,max=255,message="长度在1到32位字符")])
    method = StringField('请求方式')
    menu = IntegerField('关联菜单',validators=[data_required("关联菜单不能为空")])
    def validate_method(self,field):
        temp = eval(field.data)
        if len(temp)==0:
            raise ValidationError(message="请求方式不能为空")
Ejemplo n.º 15
0
class MyContrasenia(FlaskForm):
    """se definee campos para el formulario en la funcion cambio contrasenia """
    passw = PasswordField(
        'Contraseña',
        [validators.data_required(message="Debe ingresar una contraseña")])
    passw1 = PasswordField(
        'Repetir Contraseña',
        [validators.data_required(message="Debe ingresar una contraseña")])
    submit = SubmitField("Enviar")
Ejemplo n.º 16
0
class RegistrationForm(Form):
    username = StringField('Username', [validators.Length(min=4, max=25)])
    email = StringField('Email Address', [validators.Length(min=6, max=35)])
    password = PasswordField('New Password', [
        validators.data_required(),
        validators.EqualTo('confirm', message='Passwords must match')
    ])
    confirm = PasswordField('Repeat Password')
    accept_tos = BooleanField('I accept the TOS', [validators.data_required()])
Ejemplo n.º 17
0
class UserLoginForm(Form):
    user_id = StringField(
            label=u'아이디',
            validators=[validators.data_required(message=u'아이디를 입력하여주세요.')]
    )
    password = PasswordField(
            label=u'비밀번호',
            validators=[validators.data_required(message=u'비밀번호를 입력하여주세요.')]
    )
Ejemplo n.º 18
0
class SubjectSheetForm(Form):

    subj_name = StringField("Subject Name: ", [validators.data_required("Please, enter a name of the subject.")])
    group_code = StringField("Group code: ", [validators.data_required("Please, enter a group code of the student.")])
    study_book = StringField("Study book: ", [validators.data_required("Please, enter a study book of the student.")])
    date_of_mark = DateField("Date of Mark: ", [validators.data_required("Please, enter a date of the mark.")])
    mark = FloatField("Mark: ", [validators.data_required("Please, enter the mark.")])

    submit = SubmitField("Enter")
Ejemplo n.º 19
0
class FormularioLogin(Form):
    emailLogin = EmailField(
        "email: ",
        validators=[
            validators.data_required(message="Este campo es requerido"),
            validators.email("Ingrese un email correcto")
            # ,comprobarRedisLogin  # nosql
            # comprobarDBCorreoLogin  # mysql
        ],
        description="Email")

    emailLoginhidden = HiddenField("email")

    passwordLogin = PasswordField(
        "Password: "******"Estas obligado a rellenar este campo"),
            validators.length(min=4,
                              max=10,
                              message="Clave entre 4 y 10 caracteres")
        ],
        description="Password")

    confirmPasswordLogin = PasswordField(
        "Repite Password: "******"Estas obligado a rellenar este campo"),
            validators.equal_to("passwordLogin", "Deben ser iguales")
        ],
        description="Repite Password")

    def comprobarRedisLogin(self, form, field: StringField):
        print("comprobar correo => campo {0}".format(field.data))
        # redireccion
        ok = redisman.comprobarcorreo(field.data)
        return ok

        # if ok == False:
        #     raise ValidationError("No existe correo")

    def comprobarEmailPasswordMysql(self, form, email: StringField,
                                    password: PasswordField):
        print("comprobar correo => campo {0}".format(email.data))

        ok = sqlman.comprobarEmailLogin(email.data)
        if ok[0] == True:
            # no ha dado errores
            if ok[1] == None:
                raise ValidationError("No existe el correo")
            # else:
            #     return ok[1]
        elif ok[0] == False:
            # ok[0][1][0][0]
            raise ValidationError("Error {0}".format(ok[1]))
Ejemplo n.º 20
0
class LoginForm(Form):
    """Accepts a nickname and a room."""
    name = TextAreaField(
        'Name', [validators.data_required(),
                 validators.Length(min=1, max=20)])
    room = TextAreaField(
        'Index',
        [validators.data_required(),
         validators.Length(min=1, max=20)])
    submit = SubmitField('Enter Chatroom')
Ejemplo n.º 21
0
class MyLogin(FlaskForm):
    """se especifica los campos que tendra el formulario, el cual se usara en la funcion login() del archivo
     principal.py """
    usu = StringField(
        'Usuario',
        [validators.data_required(message="Debe ingresar un usuario")])
    passw = PasswordField(
        'Login',
        [validators.data_required(message="Debe ingresar una contraseña")])
    submit = SubmitField("Ingresar")
Ejemplo n.º 22
0
class LoginForm(FlaskForm):
    username = TextField(
        'Username*',
        [validators.data_required("Please enter \
      your name.")])
    password = PasswordField(
        'Password*',
        [validators.data_required("Please enter \
      your password.")])
    submit = SubmitField('Login')
Ejemplo n.º 23
0
class ContactForm(FlaskForm):
    name = StringField("Name",
                       validators=[data_required(),
                                   length(min=2, max=20)])
    email = StringField("Email", validators=[email(), data_required()])
    message = TextAreaField(
        "Message", validators=[data_required(),
                               length(min=2, max=200)])
    recap = RecaptchaField()
    submit = SubmitField('Submit')
Ejemplo n.º 24
0
class loginform(Form):
    username = StringField('Username', [
        validators.data_required(),
        validators.Length(
            min=4, max=50, message="Please Enter a valid Username")
    ])
    password = PasswordField('Password', [
        validators.data_required(),
        validators.Length(min=4, max=50, message="Enter a valid Password")
    ])
Ejemplo n.º 25
0
class BuildingsForm(Form):

    numb_building = StringField(
        "Number: ",
        [validators.data_required("Please, enter the case number: ")])
    json = TextField(
        "Path: ",
        [validators.data_required("Please, enter PATH map of the case: ")])

    submit = SubmitField("Enter")
Ejemplo n.º 26
0
class GroupsForm(Form):

    name_groups = StringField(
        "Groups: ", [validators.data_required("Please, enter name groups.")])
    name_faculty = StringField(
        "Faculty: ", [validators.data_required("Please, enter name faculty.")])
    count_student = IntegerField(
        "Count: ", [validators.data_required("Please, enter count student.")])

    submit = SubmitField("Enter")
Ejemplo n.º 27
0
class ProviderForm(BaseForm):
    id = StringField(
        label='Provider id',
        filters=[lambda s: s.strip() if s else s],
        validators=[data_required()],
    )
    name = StringField(
        label='Provider name',
        validators=[data_required()],
    )
Ejemplo n.º 28
0
class NewMusicForm(FlaskForm):
    name = StringField(
        'Title',
        [validators.data_required(),
         validators.Length(min=1, max=250)])
    iframe = StringField(
        'iframe',
        [validators.data_required(),
         validators.Length(min=1, max=500)])
    image = FileField()
Ejemplo n.º 29
0
class articleform(Form):
    title = StringField('Title', [
        validators.data_required(),
        validators.Length(
            min=4, max=50, message="Please Enter a valid Title of the article")
    ])
    body = TextAreaField('Body', [
        validators.data_required(),
        validators.Length(min=10, max=500, message="Enter Valid Body")
    ])
Ejemplo n.º 30
0
class JoinForm(Form):
    id = StringField(u'아이디', [validators.data_required(u'아이디를 입력하시기 바랍니다.')],
                     description={'placeholder': u'아이디를 입력하세요.'})
    email = EmailField(u'이메일', [validators.data_required(u'이메일을 입력하시기 바랍니다.')],
                       description={'placeholder': u'이메일을 입력하세요.'})
    name = StringField(u'이름', [validators.data_required(u'이름을 입력하시기 바랍니다.')],
                       description={'placeholder': u'이름을 입력하세요.'})
    password = PasswordField(u'패스워드',
                             [validators.data_required(u'패스워드를 입력하시기 바랍니다.')],
                             description={'placeholder': u'패스워드를 입력하세요.'})
Ejemplo n.º 31
0
    def test_lazy_proxy(self):
        """Tests that the validators support lazy translation strings for messages."""

        class ReallyLazyProxy(object):
            def __unicode__(self):
                raise Exception('Translator function called during form declaration: it should be called at response time.')
            __str__ = __unicode__

        message = ReallyLazyProxy()
        self.assertRaises(Exception, str, message)
        self.assertRaises(Exception, text_type, message)
        self.assertTrue(equal_to('fieldname', message=message))
        self.assertTrue(length(min=1, message=message))
        self.assertTrue(NumberRange(1, 5, message=message))
        self.assertTrue(data_required(message=message))
        self.assertTrue(regexp('.+', message=message))
        self.assertTrue(email(message=message))
        self.assertTrue(ip_address(message=message))
        self.assertTrue(url(message=message))
Ejemplo n.º 32
0
    def test_data_required(self):
        # Make sure we stop the validation chain
        self.assertEqual(data_required()(self.form, DummyField('foobar')), None)
        self.assertRaises(StopValidation, data_required(), self.form, DummyField(''))
        self.assertRaises(StopValidation, data_required(), self.form, DummyField(' '))
        self.assertEqual(data_required().field_flags, ('required', ))

        # Make sure we clobber errors
        f = DummyField('', ['Invalid Integer Value'])
        self.assertEqual(len(f.errors), 1)
        self.assertRaises(StopValidation, data_required(), self.form, f)
        self.assertEqual(len(f.errors), 0)

        # Check message and custom message
        grab = lambda **k: grab_stop_message(data_required(**k), self.form, DummyField(''))
        self.assertEqual(grab(), 'This field is required.')
        self.assertEqual(grab(message='foo'), 'foo')
Ejemplo n.º 33
0
    'TextInput',
    'FloatField',
    'IntegerField',
    'StringField',
    'ComputedStringField',
    'BaseFormMixin',
    'BaseForm',
    'SecureBaseForm',
    'json_to_form',
    'body_to_multidict',
    'HideFields',
    'GetBindingMap',
]


DATA_REQUIRED = validators.data_required()
INPUT_REQUIRED = validators.input_required()
REQUIRED = DATA_REQUIRED


def json_to_form(form_dict, sep=u'_', pre=u'', _ls=u'-'):
  """Convert a json dictionary to match the flat form fieldnames."""
  flat = []
  for key, val in form_dict.iteritems():
    key_name = pre + key if pre else key
    if isinstance(val, dict):
      leaf = json_to_form(val, sep=sep, pre=key_name + sep)
      flat += leaf
    elif isinstance(val, list) and (len(val) and isinstance(val[0], dict)):
      for i, row in enumerate(val):
        row_key = _ls.join([key_name, str(i)])
Ejemplo n.º 34
0
 def test_required(self):
     self.assertEqual(data_required()(self.form, DummyField('foobar')), None)
     self.assertRaises(StopValidation, data_required(), self.form, DummyField(''))
Ejemplo n.º 35
0
from core.forms.validators import telephone_number


__all__ = [
    'CaptchaField',
    'EmailField',
    'PasswordField',
    'HashPasswordField',
    'PhoneField',
    'TelephoneField',
    'URLField',
]


PhoneField = partial(StringField, validators=[
                data_required(message=u'手机号码为空'),
                phone_number(message=u'手机号码格式错误')
            ])

TelephoneField = partial(StringField, validators=[
                data_required(message=u'座机号码为空'),
                telephone_number(message=u'座机号码格式错误')
            ])

EmailField = partial(StringField, validators=[
                data_required(message=u'邮箱为空'),
                email(message=u'邮箱格式错误')
            ])

CaptchaField = partial(StringField, validators=[
                data_required(message=u'验证码为空'),
Ejemplo n.º 36
0
 def get_create_form(self):
     # allow user to upload a file when creating form
     form = super(FileView, self).get_create_form()
     form.upload = fields.FileField('Upload a file', [data_required()])
     return form
Ejemplo n.º 37
0
 def DataRequired(cls,message=None):
     ''' This validator checks that the ``data`` attribute on the field is a 'true' value '''
     return validators.data_required(message)