refactoring some file names and locations

This commit is contained in:
crunk 2024-03-31 11:33:03 +02:00
parent 572cb0fe16
commit b499fea9cf
6 changed files with 67 additions and 66 deletions

View File

@ -163,7 +163,7 @@ class CsvParser:
allidsincsv.append(int(row["Id"])) allidsincsv.append(int(row["Id"]))
return str(max(allidsincsv) + 1) return str(max(allidsincsv) + 1)
def writepublication(self, uploadform): def writepublication(self, publicationform):
"""When uploading a publication writes entry to the csv""" """When uploading a publication writes entry to the csv"""
id = generatenewpublicationid() id = generatenewpublicationid()
with open( with open(
@ -173,16 +173,16 @@ class CsvParser:
csv_as_writer.writerow( csv_as_writer.writerow(
{ {
"Id": id, "Id": id,
"Publication": uploadform.uploadpublication.data, "Publication": publicationform.uploadpublication.data,
"Author": uploadform.author.data, "Author": publicationform.author.data,
"Year": uploadform.year.data, "Year": publicationform.year.data,
"Fields": uploadform.fields.data, "Fields": publicationform.fields.data,
"Type": uploadform.type.data, "Type": publicationform.type.data,
"Publishers": uploadform.publishers.data, "Publishers": publicationform.publishers.data,
"License": uploadform.license.data, "License": publicationform.license.data,
"LicenseShort": uploadform.licenseshort.data, "LicenseShort": publicationform.licenseshort.data,
"Highlights": uploadform.highlights.data, "Highlights": publicationform.highlights.data,
"Comments": uploadform.comments.data, "Comments": publicationform.comments.data,
} }
) )
print("succesfully written book to csv") print("succesfully written book to csv")

View File

@ -23,15 +23,16 @@ from requests import get
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from app import create_app, login_manager from app import create_app, login_manager
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.uploadform 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
from application.user.loginuser import LoginUser from application.user.loginuser import LoginUser
from application.user.registeruser import RegisterUser from application.user.registeruser import RegisterUser
from application.user.resetpassword import ResetPassword from application.user.resetpassword import ResetPassword
from search import search
APP = create_app() APP = create_app()
csrf = CSRFProtect() csrf = CSRFProtect()
@ -71,15 +72,15 @@ def index():
@login_required @login_required
def upload(): def upload():
"""Upload route, a page to upload a book to the csv""" """Upload route, a page to upload a book to the csv"""
uploadform = PublicationForm() publicationform = PublicationForm()
if request.method == "POST": if request.method == "POST":
if uploadform.validate_on_submit(): if publicationform.validate_on_submit():
id = csvparser.writepublication(uploadform) id = csvparser.writepublication(publicationform)
saveimage(uploadform.image.data, id) saveimage(publicationform.image.data, id)
return redirect(str(id), code=303) return redirect(str(id), code=303)
else: else:
return render_template("upload.html", uploadform=uploadform) return render_template("upload.html", publicationform=publicationform)
return render_template("upload.html", uploadform=uploadform) return render_template("upload.html", publicationform=publicationform)
@APP.route("/<publicationID>", methods=["GET", "POST"]) @APP.route("/<publicationID>", methods=["GET", "POST"])

View File

@ -1,4 +1,4 @@
#uploadform { #publicationform {
max-width: 60%; max-width: 60%;
margin-top: 3em; margin-top: 3em;
margin-left: 1em; margin-left: 1em;
@ -13,12 +13,12 @@
position: relative; position: relative;
} }
.uploadform-field { .publicationform-field {
margin: 0; margin: 0;
padding: 1em 0em 1em 0em; padding: 1em 0em 1em 0em;
} }
.uploadform-field input[type=text], select { .publicationform-field input[type=text], select {
width: 100%; width: 100%;
padding: 1em 3em; padding: 1em 3em;
padding-left: 0.5em; padding-left: 0.5em;
@ -57,7 +57,7 @@ fieldset{
padding-left: 0em; padding-left: 0em;
} }
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) { @media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
#uploadform { #publicationform {
max-width: 100%; max-width: 100%;
} }
} }

View File

@ -11,92 +11,92 @@
<button id="Year" class="dropbtn">Year</button> <button id="Year" class="dropbtn">Year</button>
</div> </div>
</div> </div>
<div id="uploadform"> <div id="publicationform">
{% for message in uploadform.uploadpublication.errors %} {% for message in publicationform.uploadpublication.errors %}
<div>{{ message }}</div> <div>{{ message }}</div>
{% endfor %} {% endfor %}
{% for message in uploadform.author.errors %} {% for message in publicationform.author.errors %}
<div>{{ message }}</div> <div>{{ message }}</div>
{% endfor %} {% endfor %}
<h2 id="uploadformtitle">Upload a new book</h2> <h2 id="publicationformtitle">Upload a new book</h2>
<form method="POST" enctype="multipart/form-data" action="{{ url_for('upload') }}"> <form method="POST" enctype="multipart/form-data" action="{{ url_for('upload') }}">
{{ uploadform.csrf_token }} {{ publicationform.csrf_token }}
<fieldset class="uploadform-field"> <fieldset class="publicationform-field">
{{ uploadform.uploadpublication.label }} {{ publicationform.uploadpublication.label }}
{{ uploadform.uploadpublication }} {{ publicationform.uploadpublication }}
{% for message in uploadform.uploadpublication.errors %} {% for message in publicationform.uploadpublication.errors %}
<div class="error">{{ message }}</div> <div class="error">{{ message }}</div>
{% endfor %} {% endfor %}
</fieldset> </fieldset>
<fieldset class="uploadform-field"> <fieldset class="publicationform-field">
{{ uploadform.author.label }} {{ publicationform.author.label }}
{{ uploadform.author }} {{ publicationform.author }}
{% for message in uploadform.author.errors %} {% for message in publicationform.author.errors %}
<div class="error">{{ message }}</div> <div class="error">{{ message }}</div>
{% endfor %} {% endfor %}
</fieldset> </fieldset>
<fieldset class="uploadform-field"> <fieldset class="publicationform-field">
{{ uploadform.year.label }} {{ publicationform.year.label }}
{{ uploadform.year }} {{ publicationform.year }}
{% for message in uploadform.year.errors %} {% for message in publicationform.year.errors %}
<div class="error">{{ message }}</div> <div class="error">{{ message }}</div>
{% endfor %} {% endfor %}
</fieldset> </fieldset>
<fieldset class="uploadform-field"> <fieldset class="publicationform-field">
{{ uploadform.fields.label }} {{ publicationform.fields.label }}
{{ uploadform.fields }} {{ publicationform.fields }}
</fieldset> </fieldset>
<fieldset class="uploadform-field"> <fieldset class="publicationform-field">
{{ uploadform.type.label }} {{ publicationform.type.label }}
{{ uploadform.type }} {{ publicationform.type }}
{% for message in uploadform.type.errors %} {% for message in publicationform.type.errors %}
<div class="error">{{ message }}</div> <div class="error">{{ message }}</div>
{% endfor %} {% endfor %}
</fieldset> </fieldset>
<fieldset class="uploadform-field"> <fieldset class="publicationform-field">
{{ uploadform.publishers.label }} {{ publicationform.publishers.label }}
{{ uploadform.publishers }} {{ publicationform.publishers }}
</fieldset> </fieldset>
<fieldset class="uploadform-field"> <fieldset class="publicationform-field">
{{ uploadform.license.label }} {{ publicationform.license.label }}
{{ uploadform.license }} {{ publicationform.license }}
</fieldset> </fieldset>
<fieldset class="uploadform-field"> <fieldset class="publicationform-field">
{{ uploadform.highlights.label }} {{ publicationform.highlights.label }}
{{ uploadform.highlights }} {{ publicationform.highlights }}
</fieldset> </fieldset>
<fieldset class="uploadform-field"> <fieldset class="publicationform-field">
{{ uploadform.comments.label }} {{ publicationform.comments.label }}
{{ uploadform.comments }} {{ publicationform.comments }}
</fieldset> </fieldset>
<fieldset class="fileupload-field"> <fieldset class="fileupload-field">
{{ uploadform.image.label }} {{ publicationform.image.label }}
{{ uploadform.image }} {{ publicationform.image }}
{% for message in uploadform.image.errors %} {% for message in publicationform.image.errors %}
<div class="error">{{ message }}</div> <div class="error">{{ message }}</div>
{% endfor %} {% endfor %}
</fieldset> </fieldset>
<fieldset class="fileupload-field"> <fieldset class="fileupload-field">
{{ uploadform.pdf.label }} {{ publicationform.pdf.label }}
{{ uploadform.pdf }} {{ publicationform.pdf }}
{% for message in uploadform.pdf.errors %} {% for message in publicationform.pdf.errors %}
<div class="error">{{ message }}</div> <div class="error">{{ message }}</div>
{% endfor %} {% endfor %}
</fieldset> </fieldset>
{{ uploadform.submit }} {{ publicationform.submit }}
</form> </form>
</div> </div>
{% endblock %} {% endblock %}