-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
99 lines (87 loc) · 2.56 KB
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from flask_wtf import FlaskForm
from wtforms import PasswordField, StringField, IntegerField
from wtforms.validators import (URL, DataRequired, Email, InputRequired,
Length, Optional)
class ArticleForm(FlaskForm):
"""Form for adding articles."""
title = StringField(
'Title',
validators=[DataRequired(), InputRequired()]
)
summary = StringField(
'Summary',
validators=[Optional()]
)
content = StringField(
'Content',
validators=[DataRequired(), InputRequired()]
)
url = StringField(
'URL',
validators=[DataRequired(), InputRequired(), URL()]
)
source = StringField(
'Source',
validators=[DataRequired(), InputRequired()]
)
img_url = StringField(
'Image URL',
validators=[Optional(), URL()]
)
timestamp = StringField(
'Published At',
validators=[DataRequired(), InputRequired()]
)
class ArticleTagForm(FlaskForm):
"""Form for adding article-tag"""
article_id = IntegerField(
"Article id",
validators=[DataRequired()]
)
tag_id = IntegerField(
"Tag id",
validators=[DataRequired()]
)
class LoginForm(FlaskForm):
"""Login form."""
username = StringField(
'Username',
validators=[DataRequired(), InputRequired(), Length(min=3)]
)
password = PasswordField(
'Password',
validators=[DataRequired(), InputRequired(), Length(min=3)]
)
class RegisterForm(FlaskForm):
"""Form for adding users."""
username = StringField(
'Username', validators=[DataRequired(), InputRequired(), Length(min=3)]
)
email = StringField(
'E-mail', validators=[InputRequired(), DataRequired(), Email()]
)
password = PasswordField(
'Password', validators=[DataRequired(), InputRequired(), Length(min=3)]
)
first_name = StringField(
'First Name', validators=[DataRequired(), InputRequired()]
)
last_name = StringField(
'Last Name', validators=[DataRequired(), InputRequired()]
)
class UserEditForm(FlaskForm):
"""Form for editing users."""
username = StringField(
'Username',
validators=[DataRequired(), InputRequired(), Length(min=3)]
)
password = PasswordField(
'Verify Password',
validators=[DataRequired(), InputRequired(), Length(min=3)]
)
class TagsForm(FlaskForm):
"""Form for adding tags."""
article_url = StringField(
"Article URL",
validators=[DataRequired(), URL()]
)