crunk
6 months ago
11 changed files with 10 additions and 217 deletions
@ -1,26 +0,0 @@ |
|||||
"""Form object declaration.""" |
|
||||
from flask_wtf import FlaskForm |
|
||||
from wtforms import StringField, SubmitField, validators |
|
||||
from wtforms.validators import Length |
|
||||
|
|
||||
|
|
||||
class BorrowForm(FlaskForm): |
|
||||
"""Borrow a publication form.""" |
|
||||
|
|
||||
borrowed = StringField( |
|
||||
"Fill in your name if you're going to borrow this publication.", |
|
||||
[ |
|
||||
validators.InputRequired(), |
|
||||
Length( |
|
||||
min=3, message="Just so we know who is borrowing this book." |
|
||||
), |
|
||||
], |
|
||||
) |
|
||||
secret = StringField( |
|
||||
"Librarians secret:", |
|
||||
[ |
|
||||
validators.InputRequired(), |
|
||||
Length(min=2, message="Fill in the secret to unlock to library."), |
|
||||
], |
|
||||
) |
|
||||
submit = SubmitField("Borrow") |
|
@ -1,14 +0,0 @@ |
|||||
"""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 csv-library form""" |
|
||||
|
|
||||
email = StringField( |
|
||||
"Email address:", |
|
||||
validators=[validators.InputRequired(), Email(), Length(6, 64)], |
|
||||
) |
|
||||
submit = SubmitField("Send email") |
|
@ -1,17 +0,0 @@ |
|||||
"""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 csv-library form""" |
|
||||
|
|
||||
email = StringField( |
|
||||
"Email address:", |
|
||||
validators=[validators.InputRequired(), Email(), Length(6, 64)], |
|
||||
) |
|
||||
password = PasswordField( |
|
||||
"Password:", validators=[validators.InputRequired()] |
|
||||
) |
|
||||
submit = SubmitField("Sign In") |
|
@ -1,37 +0,0 @@ |
|||||
"""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, ValidationError |
|
||||
|
|
||||
|
|
||||
class RegisterForm(FlaskForm): |
|
||||
"""Register for csv-library form""" |
|
||||
|
|
||||
username = StringField( |
|
||||
"Username:", |
|
||||
validators=[validators.InputRequired(), Length(3, 150)], |
|
||||
) |
|
||||
|
|
||||
email = StringField( |
|
||||
"Email address:", |
|
||||
validators=[ |
|
||||
validators.InputRequired(), |
|
||||
Email(), |
|
||||
Length(6, 64), |
|
||||
], |
|
||||
) |
|
||||
|
|
||||
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 the library") |
|
@ -1,22 +0,0 @@ |
|||||
"""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 csv-library form""" |
|
||||
|
|
||||
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") |
|
@ -1,76 +0,0 @@ |
|||||
"""Form object declaration.""" |
|
||||
from flask_wtf import FlaskForm |
|
||||
from flask_wtf.file import FileAllowed, FileField |
|
||||
from wtforms import ( |
|
||||
IntegerField, |
|
||||
RadioField, |
|
||||
StringField, |
|
||||
SubmitField, |
|
||||
validators, |
|
||||
) |
|
||||
from wtforms.validators import Length, NumberRange |
|
||||
|
|
||||
|
|
||||
class PublicationForm(FlaskForm): |
|
||||
"""Publication upload form.""" |
|
||||
|
|
||||
uploadpublication = StringField( |
|
||||
"Title of the publication:", |
|
||||
[ |
|
||||
validators.InputRequired(), |
|
||||
Length( |
|
||||
min=3, message="A publication in the library needs a title." |
|
||||
), |
|
||||
], |
|
||||
) |
|
||||
author = StringField( |
|
||||
"The author or editor:", |
|
||||
[ |
|
||||
validators.InputRequired(), |
|
||||
Length( |
|
||||
min=3, |
|
||||
message=( |
|
||||
"If the author or editor is not known just type unkown." |
|
||||
), |
|
||||
), |
|
||||
], |
|
||||
) |
|
||||
year = IntegerField( |
|
||||
"Year:", |
|
||||
[validators.InputRequired(), NumberRange(min=0, max=2050)], |
|
||||
default=2023, |
|
||||
) |
|
||||
fields = StringField("Fields:") |
|
||||
type = StringField( |
|
||||
"Type of publication:", |
|
||||
[ |
|
||||
validators.InputRequired(), |
|
||||
Length( |
|
||||
min=3, |
|
||||
message=( |
|
||||
"Here you can use terms such as zine, paperback," |
|
||||
" hardcover." |
|
||||
), |
|
||||
), |
|
||||
], |
|
||||
) |
|
||||
publishers = StringField("Publishers:") |
|
||||
license = StringField("License:") |
|
||||
highlights = StringField("Highlights from the publication:") |
|
||||
comments = StringField("Comments on the publication:") |
|
||||
image = FileField( |
|
||||
"Image of the book:", |
|
||||
validators=[FileAllowed(["jpg", "png", "gif"], "Images only!")], |
|
||||
) |
|
||||
pdf = FileField( |
|
||||
"Pdf of the book:", |
|
||||
validators=[FileAllowed(["pdf"], "Only pdf uploads supported")], |
|
||||
) |
|
||||
secret = StringField( |
|
||||
"Librarians secret:", |
|
||||
[ |
|
||||
validators.InputRequired(), |
|
||||
Length(min=2, message="Fill in the secret to unlock to library."), |
|
||||
], |
|
||||
) |
|
||||
submit = SubmitField("Submit") |
|
Loading…
Reference in new issue