forms.py 2.39 KB
Newer Older
YSelf Tool's avatar
YSelf Tool committed
1
from flask.ext.wtf import Form
YSelf Tool's avatar
YSelf Tool committed
2
from wtforms import StringField, PasswordField, BooleanField, SelectMultipleField, SelectField, DateField, IntegerField, TextAreaField, HiddenField
YSelf Tool's avatar
YSelf Tool committed
3
4
5
6
7
8
9
10
11
from wtforms.validators import InputRequired, Length, EqualTo, Email, Optional, Length, NumberRange, AnyOf
from models.database import User

import shared


class LoginForm(Form):
    username = StringField("Username", validators=[InputRequired("Entering your username is required.")])
    password = PasswordField("Password", validators=[InputRequired("Entering your password is required.")])
YSelf Tool's avatar
YSelf Tool committed
12
    remember_me = BooleanField("Remember me?")
YSelf Tool's avatar
YSelf Tool committed
13
14
15
16
17
18
19
20
21
22
23

class NewUserForm(Form):
    fullname = StringField("Full name", validators=[InputRequired("Entering your name is required.")])
    username = StringField("Username", validators=[InputRequired("Entering your username is required.")])
    password = PasswordField("Password", validators=[InputRequired("Entering your password is required.")])
    confirm = PasswordField("Repeat Password", validators=[InputRequired("Entering your password is required."), EqualTo("password", message="Your passwords must match.")])

class AdminUserForm(Form):
    fullname = StringField("Full name", validators=[InputRequired("Entering the name is required.")])
    username = StringField("Username", validators=[InputRequired("Entering the username is required.")])
    roles = SelectMultipleField("User roles", choices=[(x.lower().strip(), x) for x in shared.roles])
YSelf Tool's avatar
YSelf Tool committed
24
25
26

class AddStatementForm(Form):
    speaker_name = StringField("Speaker", validators=[InputRequired("Entering the speaker is required.")])
Hinrikus Wolf's avatar
Hinrikus Wolf committed
27
    topic = HiddenField("Topic")
28
29
30
    
class AddNameToSpeaker(Form):
    speaker_name = StringField("Speaker", validators=[InputRequired("Entering the speaker is required.")])
Hinrikus Wolf's avatar
Hinrikus Wolf committed
31
32
33
    number = HiddenField("Speaker_id", validators=[NumberRange(min=0, message=None),InputRequired("ID must be a positve Integer.")])
    topic_id = HiddenField("Topic_id")
    event_id = HiddenField("Event_id")
YSelf Tool's avatar
YSelf Tool committed
34

Hinrikus Wolf's avatar
Hinrikus Wolf committed
35
36
37
class NewEventForm(Form):
    name = StringField("Name", validators=[InputRequired("Entering the name is required.")])

Hinrikus Wolf's avatar
Hinrikus Wolf committed
38
class NewTopicForm(Form):
YSelf Tool's avatar
YSelf Tool committed
39
    name = StringField("Name", validators=[InputRequired("Entering the name is required.")])
40
    mode = StringField("Mode", validators=[InputRequired("Entering the mode is required."), AnyOf(values=["balanced", "fifo"], message="Must be 'balanced' or 'fifo' atm.")])
Robin Sonnabend's avatar
Robin Sonnabend committed
41
    event_id = HiddenField("Event_id")