69 lines
1.8 KiB
Python
69 lines
1.8 KiB
Python
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")],
|
|
)
|
|
submit = SubmitField("Submit")
|