upload pdf added to template and form

This commit is contained in:
crunk 2023-12-01 15:23:37 +01:00
parent e779a764b4
commit 452bf73b84
2 changed files with 16 additions and 2 deletions

View File

@ -31,7 +31,9 @@ class PublicationForm(FlaskForm):
], ],
) )
year = IntegerField( year = IntegerField(
"Year:", [validators.InputRequired(), NumberRange(min=0, max=2050)] "Year:",
[validators.InputRequired(), NumberRange(min=0, max=2050)],
default=2023
) )
fields = StringField("Fields:") fields = StringField("Fields:")
type = StringField( type = StringField(
@ -55,6 +57,10 @@ class PublicationForm(FlaskForm):
"Image of the book:", "Image of the book:",
validators=[FileAllowed(["jpg", "png", "gif"], "Images only!")], validators=[FileAllowed(["jpg", "png", "gif"], "Images only!")],
) )
pdf = FileField(
"Pdf of the book:",
validators=[FileAllowed(["pdf"], "Only pdf uploads supported")],
)
secret = StringField( secret = StringField(
"Librarians secret:", "Librarians secret:",
[ [

View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block main %} {% block main %}
<div id="nav" class="container"> <div id="nav" class="container">
<button id="leftmostbtn"><a href="/">All books</a></button> <button id="leftmostbtn"><a href="/">Back to books</a></button>
<button><a href="/upload">Upload</a></button> <button><a href="/upload">Upload</a></button>
<div class="dropdown" style="visibility: hidden"> <div class="dropdown" style="visibility: hidden">
<button id="Year" class="dropbtn">Year</button> <button id="Year" class="dropbtn">Year</button>
@ -85,6 +85,14 @@
{% endfor %} {% endfor %}
</fieldset> </fieldset>
<fieldset class="fileupload-field">
{{ uploadform.pdf.label }}
{{ uploadform.pdf }}
{% for message in uploadform.pdf.errors %}
<div class="error">{{ message }}</div>
{% endfor %}
</fieldset>
<fieldset class="uploadform-field"> <fieldset class="uploadform-field">
{{ uploadform.secret.label }} {{ uploadform.secret.label }}
{{ uploadform.secret }} {{ uploadform.secret }}