refactoring some file names and locations
This commit is contained in:
parent
572cb0fe16
commit
b499fea9cf
@ -163,7 +163,7 @@ class CsvParser:
|
||||
allidsincsv.append(int(row["Id"]))
|
||||
return str(max(allidsincsv) + 1)
|
||||
|
||||
def writepublication(self, uploadform):
|
||||
def writepublication(self, publicationform):
|
||||
"""When uploading a publication writes entry to the csv"""
|
||||
id = generatenewpublicationid()
|
||||
with open(
|
||||
@ -173,16 +173,16 @@ class CsvParser:
|
||||
csv_as_writer.writerow(
|
||||
{
|
||||
"Id": id,
|
||||
"Publication": uploadform.uploadpublication.data,
|
||||
"Author": uploadform.author.data,
|
||||
"Year": uploadform.year.data,
|
||||
"Fields": uploadform.fields.data,
|
||||
"Type": uploadform.type.data,
|
||||
"Publishers": uploadform.publishers.data,
|
||||
"License": uploadform.license.data,
|
||||
"LicenseShort": uploadform.licenseshort.data,
|
||||
"Highlights": uploadform.highlights.data,
|
||||
"Comments": uploadform.comments.data,
|
||||
"Publication": publicationform.uploadpublication.data,
|
||||
"Author": publicationform.author.data,
|
||||
"Year": publicationform.year.data,
|
||||
"Fields": publicationform.fields.data,
|
||||
"Type": publicationform.type.data,
|
||||
"Publishers": publicationform.publishers.data,
|
||||
"License": publicationform.license.data,
|
||||
"LicenseShort": publicationform.licenseshort.data,
|
||||
"Highlights": publicationform.highlights.data,
|
||||
"Comments": publicationform.comments.data,
|
||||
}
|
||||
)
|
||||
print("succesfully written book to csv")
|
||||
|
@ -23,15 +23,16 @@ from requests import get
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
from app import create_app, login_manager
|
||||
from application.search import search
|
||||
from application.csvparser import CsvParser
|
||||
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.user.forgotpassword import ForgotPassword
|
||||
from application.user.loginuser import LoginUser
|
||||
from application.user.registeruser import RegisterUser
|
||||
from application.user.resetpassword import ResetPassword
|
||||
from search import search
|
||||
|
||||
|
||||
APP = create_app()
|
||||
csrf = CSRFProtect()
|
||||
@ -71,15 +72,15 @@ def index():
|
||||
@login_required
|
||||
def upload():
|
||||
"""Upload route, a page to upload a book to the csv"""
|
||||
uploadform = PublicationForm()
|
||||
publicationform = PublicationForm()
|
||||
if request.method == "POST":
|
||||
if uploadform.validate_on_submit():
|
||||
id = csvparser.writepublication(uploadform)
|
||||
saveimage(uploadform.image.data, id)
|
||||
if publicationform.validate_on_submit():
|
||||
id = csvparser.writepublication(publicationform)
|
||||
saveimage(publicationform.image.data, id)
|
||||
return redirect(str(id), code=303)
|
||||
else:
|
||||
return render_template("upload.html", uploadform=uploadform)
|
||||
return render_template("upload.html", uploadform=uploadform)
|
||||
return render_template("upload.html", publicationform=publicationform)
|
||||
return render_template("upload.html", publicationform=publicationform)
|
||||
|
||||
|
||||
@APP.route("/<publicationID>", methods=["GET", "POST"])
|
||||
|
@ -1,4 +1,4 @@
|
||||
#uploadform {
|
||||
#publicationform {
|
||||
max-width: 60%;
|
||||
margin-top: 3em;
|
||||
margin-left: 1em;
|
||||
@ -13,12 +13,12 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.uploadform-field {
|
||||
.publicationform-field {
|
||||
margin: 0;
|
||||
padding: 1em 0em 1em 0em;
|
||||
}
|
||||
|
||||
.uploadform-field input[type=text], select {
|
||||
.publicationform-field input[type=text], select {
|
||||
width: 100%;
|
||||
padding: 1em 3em;
|
||||
padding-left: 0.5em;
|
||||
@ -57,7 +57,7 @@ fieldset{
|
||||
padding-left: 0em;
|
||||
}
|
||||
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
|
||||
#uploadform {
|
||||
#publicationform {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
@ -11,92 +11,92 @@
|
||||
<button id="Year" class="dropbtn">Year</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="uploadform">
|
||||
<div id="publicationform">
|
||||
|
||||
{% for message in uploadform.uploadpublication.errors %}
|
||||
{% for message in publicationform.uploadpublication.errors %}
|
||||
<div>{{ message }}</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for message in uploadform.author.errors %}
|
||||
{% for message in publicationform.author.errors %}
|
||||
<div>{{ message }}</div>
|
||||
{% 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') }}">
|
||||
{{ uploadform.csrf_token }}
|
||||
<fieldset class="uploadform-field">
|
||||
{{ uploadform.uploadpublication.label }}
|
||||
{{ uploadform.uploadpublication }}
|
||||
{% for message in uploadform.uploadpublication.errors %}
|
||||
{{ publicationform.csrf_token }}
|
||||
<fieldset class="publicationform-field">
|
||||
{{ publicationform.uploadpublication.label }}
|
||||
{{ publicationform.uploadpublication }}
|
||||
{% for message in publicationform.uploadpublication.errors %}
|
||||
<div class="error">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="uploadform-field">
|
||||
{{ uploadform.author.label }}
|
||||
{{ uploadform.author }}
|
||||
{% for message in uploadform.author.errors %}
|
||||
<fieldset class="publicationform-field">
|
||||
{{ publicationform.author.label }}
|
||||
{{ publicationform.author }}
|
||||
{% for message in publicationform.author.errors %}
|
||||
<div class="error">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="uploadform-field">
|
||||
{{ uploadform.year.label }}
|
||||
{{ uploadform.year }}
|
||||
{% for message in uploadform.year.errors %}
|
||||
<fieldset class="publicationform-field">
|
||||
{{ publicationform.year.label }}
|
||||
{{ publicationform.year }}
|
||||
{% for message in publicationform.year.errors %}
|
||||
<div class="error">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="uploadform-field">
|
||||
{{ uploadform.fields.label }}
|
||||
{{ uploadform.fields }}
|
||||
<fieldset class="publicationform-field">
|
||||
{{ publicationform.fields.label }}
|
||||
{{ publicationform.fields }}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="uploadform-field">
|
||||
{{ uploadform.type.label }}
|
||||
{{ uploadform.type }}
|
||||
{% for message in uploadform.type.errors %}
|
||||
<fieldset class="publicationform-field">
|
||||
{{ publicationform.type.label }}
|
||||
{{ publicationform.type }}
|
||||
{% for message in publicationform.type.errors %}
|
||||
<div class="error">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="uploadform-field">
|
||||
{{ uploadform.publishers.label }}
|
||||
{{ uploadform.publishers }}
|
||||
<fieldset class="publicationform-field">
|
||||
{{ publicationform.publishers.label }}
|
||||
{{ publicationform.publishers }}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="uploadform-field">
|
||||
{{ uploadform.license.label }}
|
||||
{{ uploadform.license }}
|
||||
<fieldset class="publicationform-field">
|
||||
{{ publicationform.license.label }}
|
||||
{{ publicationform.license }}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="uploadform-field">
|
||||
{{ uploadform.highlights.label }}
|
||||
{{ uploadform.highlights }}
|
||||
<fieldset class="publicationform-field">
|
||||
{{ publicationform.highlights.label }}
|
||||
{{ publicationform.highlights }}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="uploadform-field">
|
||||
{{ uploadform.comments.label }}
|
||||
{{ uploadform.comments }}
|
||||
<fieldset class="publicationform-field">
|
||||
{{ publicationform.comments.label }}
|
||||
{{ publicationform.comments }}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fileupload-field">
|
||||
{{ uploadform.image.label }}
|
||||
{{ uploadform.image }}
|
||||
{% for message in uploadform.image.errors %}
|
||||
{{ publicationform.image.label }}
|
||||
{{ publicationform.image }}
|
||||
{% for message in publicationform.image.errors %}
|
||||
<div class="error">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fileupload-field">
|
||||
{{ uploadform.pdf.label }}
|
||||
{{ uploadform.pdf }}
|
||||
{% for message in uploadform.pdf.errors %}
|
||||
{{ publicationform.pdf.label }}
|
||||
{{ publicationform.pdf }}
|
||||
{% for message in publicationform.pdf.errors %}
|
||||
<div class="error">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
{{ uploadform.submit }}
|
||||
{{ publicationform.submit }}
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user