You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.0 KiB
76 lines
2.0 KiB
4 years ago
|
"""Form object declaration."""
|
||
|
from flask_wtf import FlaskForm
|
||
4 years ago
|
from flask_wtf.file import FileField, FileAllowed
|
||
|
from wtforms import validators
|
||
4 years ago
|
from wtforms import (
|
||
|
StringField,
|
||
|
IntegerField,
|
||
|
RadioField,
|
||
|
SubmitField,
|
||
|
)
|
||
4 years ago
|
from wtforms.validators import (
|
||
|
Length,
|
||
|
NumberRange,
|
||
|
)
|
||
4 years ago
|
|
||
|
|
||
|
class PublicationForm(FlaskForm):
|
||
4 years ago
|
"""Publication upload form."""
|
||
4 years ago
|
|
||
4 years ago
|
uploadpublication = StringField(
|
||
4 years ago
|
"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)]
|
||
|
)
|
||
|
custodian = StringField("Custodian:")
|
||
|
fields = StringField("Fields:")
|
||
|
type = StringField(
|
||
|
"Type of publication:",
|
||
|
[
|
||
|
validators.InputRequired(),
|
||
|
Length(
|
||
|
min=3,
|
||
|
message=(
|
||
|
"Here you can use terms such as zine, paperback,"
|
||
|
" hardcover."
|
||
|
),
|
||
|
),
|
||
|
],
|
||
4 years ago
|
)
|
||
4 years ago
|
publishers = StringField("Publishers:")
|
||
|
license = StringField("License:")
|
||
3 years ago
|
highlights = StringField("Highlights from the publication:")
|
||
|
comments = StringField("Comments on the publication:")
|
||
4 years ago
|
borrowed = StringField("Currently borrowed by:")
|
||
3 years ago
|
image = FileField(
|
||
|
"Image of the book:",
|
||
|
validators=[FileAllowed(["jpg", "png", "gif"], "Images only!")],
|
||
|
)
|
||
4 years ago
|
secret = StringField(
|
||
|
"Librarians secret:",
|
||
|
[
|
||
|
validators.InputRequired(),
|
||
3 years ago
|
Length(min=2, message="Fill in the secret to unlock to library."),
|
||
4 years ago
|
],
|
||
|
)
|
||
4 years ago
|
submit = SubmitField("Submit")
|