from flask_wtf import FlaskForm from wtforms import StringField, SubmitField, PasswordField; 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')