2021-03-07 19:55:47 +01:00
|
|
|
"""Form object declaration."""
|
|
|
|
from flask_wtf import FlaskForm
|
2021-04-17 23:34:28 +02:00
|
|
|
from flask_wtf.file import FileField, FileAllowed
|
|
|
|
from wtforms import validators
|
2021-03-07 20:08:17 +01:00
|
|
|
from wtforms import (
|
|
|
|
StringField,
|
|
|
|
IntegerField,
|
|
|
|
RadioField,
|
|
|
|
SubmitField,
|
|
|
|
)
|
2021-04-05 21:42:43 +02:00
|
|
|
from wtforms.validators import (
|
|
|
|
Length,
|
|
|
|
NumberRange,
|
|
|
|
)
|
2021-03-07 19:55:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
class PublicationForm(FlaskForm):
|
2021-04-05 21:42:43 +02:00
|
|
|
"""Publication upload form."""
|
2021-03-07 20:08:17 +01:00
|
|
|
|
2021-03-07 19:55:47 +01:00
|
|
|
uploadpublication = StringField(
|
2021-04-05 21:42:43 +02:00
|
|
|
"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."
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2021-03-07 20:08:17 +01:00
|
|
|
)
|
2021-04-05 21:42:43 +02:00
|
|
|
publishers = StringField("Publishers:")
|
|
|
|
license = StringField("License:")
|
2021-03-07 19:55:47 +01:00
|
|
|
licenseshort = RadioField(
|
2021-03-07 20:08:17 +01:00
|
|
|
"Select the closest license type:",
|
|
|
|
choices=[
|
|
|
|
("Anti-copyright", "Anti-copyright"),
|
|
|
|
("No License Mentioned", "No License Mentioned"),
|
|
|
|
("Free Art License", "Free Art License"),
|
|
|
|
("Copyright", "Copyright"),
|
|
|
|
("Copyleft", "Copyleft"),
|
|
|
|
("Creative Commons", "Creative Commons"),
|
|
|
|
("Public Domain", "Public Domain"),
|
|
|
|
(
|
|
|
|
"GNU Free Documentation License",
|
|
|
|
"GNU Free Documentation License",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2022-04-18 21:27:35 +02:00
|
|
|
highlights = StringField("Highlights from the publication:")
|
|
|
|
comments = StringField("Comments on the publication:")
|
2021-03-07 20:08:17 +01:00
|
|
|
borrowed = StringField("Currently borrowed by:")
|
2022-04-18 21:27:35 +02:00
|
|
|
image = FileField(
|
|
|
|
"Image of the book:",
|
|
|
|
validators=[FileAllowed(["jpg", "png", "gif"], "Images only!")],
|
|
|
|
)
|
2021-04-17 21:15:45 +02:00
|
|
|
secret = StringField(
|
|
|
|
"Librarians secret:",
|
|
|
|
[
|
|
|
|
validators.InputRequired(),
|
2022-04-18 21:27:35 +02:00
|
|
|
Length(min=2, message="Fill in the secret to unlock to library."),
|
2021-04-17 21:15:45 +02:00
|
|
|
],
|
|
|
|
)
|
2021-03-07 20:08:17 +01:00
|
|
|
submit = SubmitField("Submit")
|