template for pdf and image upload
This commit is contained in:
parent
e521349ad5
commit
b6c001b8eb
@ -26,6 +26,8 @@ from app import create_app, login_manager
|
|||||||
from application.search import search
|
from application.search import search
|
||||||
from application.csvparser import CsvParser
|
from application.csvparser import CsvParser
|
||||||
from application.forms.borrowform import BorrowForm
|
from application.forms.borrowform import BorrowForm
|
||||||
|
from application.forms.image_uploadform import ImageUploadForm
|
||||||
|
from application.forms.pdf_uploadform import PdfUploadForm
|
||||||
from application.forms.publicationform import PublicationForm
|
from application.forms.publicationform import PublicationForm
|
||||||
from application.models.usermodel import User
|
from application.models.usermodel import User
|
||||||
from application.user.forgotpassword import ForgotPassword
|
from application.user.forgotpassword import ForgotPassword
|
||||||
@ -88,22 +90,23 @@ def show_book(publicationID):
|
|||||||
"""route for a single publication, shows full info and allows borrowing"""
|
"""route for a single publication, shows full info and allows borrowing"""
|
||||||
fullpublication = csvparser.getfullpublication(publicationID)
|
fullpublication = csvparser.getfullpublication(publicationID)
|
||||||
borrowform = BorrowForm()
|
borrowform = BorrowForm()
|
||||||
|
image_uploadform = ImageUploadForm()
|
||||||
|
pdf_uploadform = PdfUploadForm()
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if borrowform.validate_on_submit():
|
if borrowform.validate_on_submit():
|
||||||
editborrowedby(publicationID, borrowform.borrowed.data)
|
editborrowedby(publicationID, borrowform.borrowed.data)
|
||||||
fullpublication["Borrowed"] = borrowform.borrowed.data
|
fullpublication["Borrowed"] = borrowform.borrowed.data
|
||||||
return render_template(
|
if image_uploadform.validate_on_submit():
|
||||||
"publication.html",
|
saveimage(image_uploadform.image.data, fullpublication.id)
|
||||||
fullpublication=fullpublication,
|
|
||||||
publicationID=publicationID,
|
|
||||||
borrowform=borrowform,
|
|
||||||
)
|
|
||||||
# return a full publication with or without form errors
|
# return a full publication with or without form errors
|
||||||
return render_template(
|
return render_template(
|
||||||
"publication.html",
|
"publication.html",
|
||||||
fullpublication=fullpublication,
|
fullpublication=fullpublication,
|
||||||
publicationID=publicationID,
|
publicationID=publicationID,
|
||||||
borrowform=borrowform,
|
borrowform=borrowform,
|
||||||
|
image_uploadform=image_uploadform,
|
||||||
|
pdf_uploadform=pdf_uploadform,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ html, body {
|
|||||||
#bookshelf {
|
#bookshelf {
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
margin-top: 3em;
|
margin-top: 3em;
|
||||||
|
margin-bottom: 3em;
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
display: block;
|
display: block;
|
||||||
columns: 30rem;
|
columns: 30rem;
|
||||||
|
@ -64,6 +64,40 @@
|
|||||||
<td>File</td>
|
<td>File</td>
|
||||||
<td><a href='files/{{fullpublication["Files"]}}'><p>{{ fullpublication["Files"] }}</p></a></td>
|
<td><a href='files/{{fullpublication["Files"]}}'><p>{{ fullpublication["Files"] }}</p></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% if current_user.is_authenticated %}
|
||||||
|
<tr>
|
||||||
|
<td>Upload new</td>
|
||||||
|
<td>
|
||||||
|
<form method="POST" enctype="multipart/form-data" action="/{{ publicationID }}">
|
||||||
|
{{ pdf_uploadform.csrf_token }}
|
||||||
|
<fieldset class="fileupload-field">
|
||||||
|
{{ pdf_uploadform.pdf.label }}
|
||||||
|
{{ pdf_uploadform.pdf }}
|
||||||
|
{% for message in pdf_uploadform.pdf.errors %}
|
||||||
|
<div class="error">{{ message }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
</fieldset>
|
||||||
|
{{ pdf_uploadform.submit }}
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Upload new</td>
|
||||||
|
<td>
|
||||||
|
<form method="POST" enctype="multipart/form-data" action="/{{ publicationID }}">
|
||||||
|
{{ image_uploadform.csrf_token }}
|
||||||
|
<fieldset class="fileupload-field">
|
||||||
|
{{ image_uploadform.image.label }}
|
||||||
|
{{ image_uploadform.image }}
|
||||||
|
{% for message in image_uploadform.image.errors %}
|
||||||
|
<div class="error">{{ message }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
</fieldset>
|
||||||
|
{{ image_uploadform.submit }}
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user