flaschengeist/geruecht/forms.py

24 lines
791 B
Python
Raw Normal View History

2019-01-13 19:07:46 +00:00
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, PasswordField;
2019-01-13 19:07:46 +00:00
from wtforms.validators import DataRequired, Length, ValidationError
from geruecht.model import User
class RegistrationForm(FlaskForm):
username = StringField('Name', validators=[DataRequired(), Length(min=2, max=20)])
submit = SubmitField('Create')
def validate_username(self, username):
user = User.query.filter_by(username=username.data).first()
if user:
raise ValidationError('Bist du behindert!? Der Name ist vergeben!!')
class FinanzerLogin(FlaskForm):
username = StringField('Name', validators=[DataRequired(), Length(min=2, max=20)])
password = PasswordField('Password', validators=[DataRequired()])
submit = SubmitField('Login')