required forms

This commit is contained in:
crunk 2024-03-31 11:51:44 +02:00
parent b499fea9cf
commit fd3ee119fb
5 changed files with 28 additions and 10 deletions

View File

@ -1,4 +1,3 @@
"""Form object declaration."""
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, validators
from wtforms.validators import Length

View File

@ -1,4 +1,3 @@
"""Forgotten password form to help user."""
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, validators
from wtforms.validators import Email, Length

View File

@ -0,0 +1,14 @@
from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed, FileField
from wtforms import (
SubmitField,
validators,
)
class ImageUploadForm(FlaskForm):
"""Image upload form."""
image = FileField(
"Image of the book:",
validators=[FileAllowed(["jpg", "png", "gif", "webp"], "Images only!")],
)
submit = SubmitField("Submit")

View File

@ -0,0 +1,14 @@
from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed, FileField
from wtforms import (
SubmitField,
validators,
)
class PdfUploadForm(FlaskForm):
"""Pdf upload form."""
pdf = FileField(
"Pdf of the book:",
validators=[FileAllowed(["pdf"], "Only pdf uploads supported")],
)
submit = SubmitField("Submit")

View File

@ -1,4 +1,3 @@
"""Form object declaration."""
from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed, FileField
from wtforms import (
@ -66,11 +65,4 @@ class PublicationForm(FlaskForm):
"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")