refactor: moved user forms to statuspengguna folder

This commit is contained in:
crunk 2024-06-02 22:16:52 +02:00
parent b5c9bfc8d7
commit 280ce2f196
7 changed files with 97 additions and 3 deletions

View File

@ -0,0 +1,15 @@
"""Forgotten password form to help user."""
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, validators
from wtforms.validators import Email, Length
class ForgotPasswordForm(FlaskForm):
"""Forgotten password distribusiverse form class."""
email = StringField(
"Email address:",
validators=[validators.InputRequired(), Email(), Length(6, 64)],
)
submit = SubmitField("Send email")

View File

@ -0,0 +1,18 @@
"""Login form to validate user."""
from flask_wtf import FlaskForm
from wtforms import PasswordField, StringField, SubmitField, validators
from wtforms.validators import Email, Length
class LoginForm(FlaskForm):
"""Login distribusiverse form class."""
email = StringField(
"Email address:",
validators=[validators.InputRequired(), Email(), Length(6, 64)],
)
password = PasswordField(
"Password:", validators=[validators.InputRequired()]
)
submit = SubmitField("Sign In")

View File

@ -0,0 +1,38 @@
"""Register form to make a new user."""
from flask_wtf import FlaskForm
from wtforms import PasswordField, StringField, SubmitField, validators
from wtforms.validators import Email, EqualTo, Length
class RegisterForm(FlaskForm):
"""Register for distribusi-verse form class"""
username = StringField(
"Username:",
validators=[validators.InputRequired(), Length(3, 150)],
)
email = StringField(
"Email address:",
validators=[
validators.InputRequired(),
Email(),
Length(6, 128),
],
)
password = PasswordField(
"New password:",
validators=[validators.InputRequired(), Length(12, 72)],
)
confirmpassword = PasswordField(
"Confirm your password:",
validators=[
validators.InputRequired(),
Length(12, 72),
EqualTo("password", message="Passwords must match !"),
],
)
submit = SubmitField("Register to Distribusi-verse")

View File

@ -0,0 +1,23 @@
"""Reset Password Form form to reset a users PasswordField."""
from flask_wtf import FlaskForm
from wtforms import PasswordField, SubmitField, validators
from wtforms.validators import EqualTo, Length
class ResetPasswordForm(FlaskForm):
"""ResetPassword for distribusi-verse form class"""
password = PasswordField(
"New password:",
validators=[validators.InputRequired(), Length(12, 72)],
)
confirmpassword = PasswordField(
"Confirm your password:",
validators=[
validators.InputRequired(),
Length(12, 72),
EqualTo("password", message="Passwords must match !"),
],
)
submit = SubmitField("Reset your password")

View File

@ -10,7 +10,7 @@ from flask import (
from flask_bcrypt import check_password_hash
from flask_login import login_user
from forms.loginform import LoginForm
from statuspengguna.forms.loginform import LoginForm
from models.user_model import User
login_section = Blueprint(

View File

@ -11,7 +11,7 @@ from sqlalchemy.exc import (
from werkzeug.routing import BuildError
from app import db
from forms.registerform import RegisterForm
from statuspengguna.forms.registerform import RegisterForm
from models.user_model import User
register_user = Blueprint(

View File

@ -13,7 +13,7 @@ from sqlalchemy.exc import (
from werkzeug.routing import BuildError
from app import db
from forms.resetpasswordform import ResetPasswordForm
from statuspengguna.forms.resetpasswordform import ResetPasswordForm
from models.user_model import User
reset_password = Blueprint(