Skip to content

Commit d97d3ce

Browse files
committed
update flask_wtform
1 parent c76cc13 commit d97d3ce

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

app/accounts/forms.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
from flask_wtf import Form
4+
from flask_wtf import FlaskForm
55
from wtforms import StringField, PasswordField, BooleanField, SelectField, ValidationError
66
from wtforms.validators import Required, Length, Email, Regexp, EqualTo, URL, Optional
77
# from flask.ext.login import current_user
@@ -11,12 +11,12 @@
1111

1212
from . 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()])

app/main/forms.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
# from flask.ext.mongoengine.wtf import model_form
55
from flask_mongoengine.wtf import model_form
6-
from flask_wtf import Form
6+
from flask_wtf import FlaskForm
77
from wtforms import StringField, PasswordField, BooleanField, TextAreaField, HiddenField, RadioField, FileField
88
from wtforms import widgets, ValidationError
99
from wtforms.validators import Required, Length, Email, Regexp, EqualTo, URL, Optional
1010

1111
from . import models
1212

13-
class PostForm(Form):
13+
class PostForm(FlaskForm):
1414
title = StringField('Title', validators=[Required()])
1515
slug = StringField('Slug', validators=[Required()])
1616
raw = TextAreaField('Content')
@@ -32,26 +32,26 @@ def validate_slug(self, field):
3232

3333
SuPostForm = model_form(models.Post, exclude=['pub_time', 'update_time', 'content_html', 'category', 'tags', 'post_type'])
3434

35-
class WidgetForm(Form):
35+
class WidgetForm(FlaskForm):
3636
title = StringField('Title', validators=[Required()])
3737
content = TextAreaField('Content', validators=[Required()])
3838
content_type = RadioField('Content Type', choices=[('markdown', 'markdown'), ('html', 'html')], default='html')
3939

40-
class CommentForm(Form):
40+
class CommentForm(FlaskForm):
4141
email = StringField('* Email', validators=[Required(), Length(1,128), Email()])
4242
author = StringField('* Name', validators=[Required(), Length(1,128)])
4343
homepage = StringField('Homepage', validators=[URL(), Optional()])
4444
content = TextAreaField('* Comment <small><span class="label label-info">markdown</span></small>', validators=[Required()])
4545
comment_id = HiddenField('comment_id')
4646

47-
class SessionCommentForm(Form):
47+
class SessionCommentForm(FlaskForm):
4848
email = HiddenField('* Email')
4949
author = HiddenField('* Name')
5050
homepage = HiddenField('Homepage')
5151
content = TextAreaField('* Comment', validators=[Required()])
5252
comment_id = HiddenField('comment_id')
5353

54-
class ImportCommentForm(Form):
54+
class ImportCommentForm(FlaskForm):
5555
content = TextAreaField('Content')
5656
json_file = FileField('Json File')
5757
import_format = RadioField('Import Format', choices=[('text', 'text'), ('file', 'file')], default='text')

app/templates/base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
<link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
3636
<link href="//cdn.bootcss.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
3737
<!-- Custom CSS -->
38-
<!-- <link href="{{ url_for('static', filename='css/clean-blog.css') }}" rel="stylesheet"> -->
39-
<link rel="stylesheet" href="//cdn.bootcss.com/startbootstrap-clean-blog/3.3.7/css/clean-blog.min.css">
38+
<link href="{{ url_for('static', filename='css/clean-blog.css') }}" rel="stylesheet">
39+
<!-- <link rel="stylesheet" href="//cdn.bootcss.com/startbootstrap-clean-blog/3.3.7/css/clean-blog.min.css"> -->
4040
<link href="{{ url_for('static', filename='css/octblog.css') }}" rel="stylesheet">
4141
<link rel="stylesheet" href="//cdn.bootcss.com/highlight.js/9.9.0/styles/default.min.css">
4242

0 commit comments

Comments
 (0)