11#!/usr/bin/env python
22# -*- coding: utf-8 -*-
33
4- from flask_wtf import Form
4+ from flask_wtf import FlaskForm
55from wtforms import StringField , PasswordField , BooleanField , SelectField , ValidationError
66from wtforms .validators import Required , Length , Email , Regexp , EqualTo , URL , Optional
77# from flask.ext.login import current_user
1111
1212from . import models
1313
14- class LoginForm (Form ):
14+ class LoginForm (FlaskForm ):
1515 username = StringField ()
1616 password = PasswordField ()
1717 remember_me = BooleanField ('Keep me logged in' )
1818
19- class RegistrationForm (Form ):
19+ class RegistrationForm (FlaskForm ):
2020 username = StringField ('Username' , validators = [Required (), Length (1 ,64 ),
2121 Regexp ('^[A-Za-z0-9_.]*$' , 0 , 'Usernames must have only letters, numbers dots or underscores' )])
2222 email = StringField ('Email' , validators = [Required (), Length (1 ,128 ), Email ()])
@@ -31,15 +31,15 @@ def validate_email(self, field):
3131 if models .User .objects .filter (email = field .data ).count () > 0 :
3232 raise ValidationError ('Email already in registered' )
3333
34- class UserForm (Form ):
34+ class UserForm (FlaskForm ):
3535 email = StringField ('Email' , validators = [Required (), Length (1 ,128 ), Email ()])
3636 # is_active = BooleanField('Is activie')
3737 # is_superuser = BooleanField('Is superuser')
3838 role = SelectField ('Role' , choices = models .ROLES )
3939
4040# SuUserForm = model_form(models.User, exclude=['create_time', 'last_login', 'password_hash'])
4141
42- class SuUserForm (Form ):
42+ class SuUserForm (FlaskForm ):
4343 email = StringField ('Email' , validators = [Required (), Length (1 ,128 ), Email ()])
4444 is_superuser = BooleanField ('Is superuser' )
4545 is_email_confirmed = BooleanField ('Is Email Confirmed' )
@@ -56,7 +56,7 @@ class SuUserForm(Form):
5656
5757# ProfileForm = model_form(models.User, exclude=['username', 'password_hash', 'create_time', 'last_login',
5858# 'is_email_confirmed', 'is_superuser', 'role'])
59- class ProfileForm (Form ):
59+ class ProfileForm (FlaskForm ):
6060 email = StringField ('Email' , validators = [Required (), Length (1 ,128 ), Email ()])
6161 display_name = StringField ('Display Name' , validators = [Length (1 ,128 )])
6262 biography = StringField ('Biograpyh' )
@@ -68,7 +68,7 @@ class ProfileForm(Form):
6868 facebook = StringField ('Facebook' , validators = [URL (), Optional ()])
6969 linkedin = StringField ('Linkedin' , validators = [URL (), Optional ()])
7070
71- class PasswordForm (Form ):
71+ class PasswordForm (FlaskForm ):
7272 current_password = PasswordField ('Current Password' , validators = [Required ()])
7373 new_password = PasswordField ('New Password' , validators = [Required (), EqualTo ('password2' , message = 'Passwords must match' )])
7474 password2 = PasswordField ('Confirm password' , validators = [Required ()])
0 commit comments