<filename>app/forms.py
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField, SelectField, TimeField, DateField, TextAreaField
from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length
from app.models import User, Event, user_favorites
from flask_login import current_user

class LoginForm(FlaskForm):
    email = StringField('Email', validators=[DataRequired()])
    password = PasswordField('Password', validators=[DataRequired()])
    remember_me = BooleanField('Remember Me')
    submit = SubmitField('Sign In')

    def validate_email(self, email):
        user = User.query.filter_by(email=email.data).first()
        if user is None:
            raise ValidationError('Invalid username')


class RegistrationForm(FlaskForm):
    name = StringField('Name', validators=[DataRequired(), Length(max=50)])
    email = StringField('Email', validators=[DataRequired(), Email(), Length(max=50)])
    password = PasswordField('Password', validators=[DataRequired(), Length(min=8)])
    password2 = PasswordField('<PASSWORD>', validators=[DataRequired(), EqualTo('password'), Length(min=8)])
    submit = SubmitField('Create Account')

    def validate_email(self, email):
        user = User.query.filter_by(email=email.data).first()
        if user is not None:
            raise ValidationError('This email is already in use')


class EditForm(FlaskForm):
    name = StringField('Name')
    old_password = PasswordField('<PASSWORD>', validators=[Length(min=8)])
    new_password = PasswordField('<PASSWORD>', validators=[Length(min=8)])
    confirm = PasswordField('Confirm New Password', validators=[Length(min=8), EqualTo('new_password')])
    submit = SubmitField('Save')


<filename>app/forms.py
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField, SelectField, TimeField, DateField, TextAreaField
from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length
from app.models import User, Event, user_favorites
from flask_login import current_user

class LoginForm(FlaskForm):
    email = StringField('Email', validators=[DataRequired()])
    password = PasswordField('Password', validators=[DataRequired()])
    remember_me = BooleanField('Remember Me')
    submit = SubmitField('Sign In')

    def validate_email(self, email):
        user = User.query.filter_by(email=email.data).first()
        if user is None:
            raise ValidationError('Invalid username')


class RegistrationForm(FlaskForm):
    name = StringField('Name', validators=[DataRequired(), Length(max=50)])
    email = StringField('Email', validators=[DataRequired(), Email(), Length(max=50)])
    password = PasswordField('Password', validators=[DataRequired(), Length(min=8)])
    password2 = PasswordField('<PASSWORD>', validators=[DataRequired(), EqualTo('password'), Length(min=8)])
    submit = SubmitField('Create Account')

    def validate_email(self, email):
        user = User.query.filter_by(email=email.data).first()
        if user is not None:
            raise ValidationError('This email is already in use')


class EditForm(FlaskForm):
    name = StringField('Name')
    old_password = PasswordField('<PASSWORD>', validators=[Length(min=8)])
    new_password = PasswordField('<PASSWORD>', validators=[Length(min=8)])
    confirm = PasswordField('Confirm New Password', validators=[Length(min=8), EqualTo('new_password')])
    submit = SubmitField('Save')

