|
@ -4,7 +4,7 @@ import string |
|
|
from pathlib import Path |
|
|
from pathlib import Path |
|
|
|
|
|
|
|
|
import petname |
|
|
import petname |
|
|
from flask import Flask, redirect, render_template, request, url_for |
|
|
from flask import Flask, flash, redirect, render_template, request, url_for |
|
|
from flask_wtf import FlaskForm |
|
|
from flask_wtf import FlaskForm |
|
|
from flask_wtf.csrf import CSRFProtect |
|
|
from flask_wtf.csrf import CSRFProtect |
|
|
from flask_wtf.file import FileAllowed, FileField, FileRequired |
|
|
from flask_wtf.file import FileAllowed, FileField, FileRequired |
|
@ -74,6 +74,19 @@ def upload(): |
|
|
upload_form = UploadForm() |
|
|
upload_form = UploadForm() |
|
|
|
|
|
|
|
|
if upload_form.validate_on_submit(): |
|
|
if upload_form.validate_on_submit(): |
|
|
|
|
|
if not upload_form.metadata.data: |
|
|
|
|
|
pname = upload_form.petname.data |
|
|
|
|
|
metadata_name = "metadata-{}.db".format(pname) |
|
|
|
|
|
if not Path(os.path.join(CWD, "metadatum", metadata_name)).exists(): |
|
|
|
|
|
flash("Woops, you forgot to upload a metadata file?") |
|
|
|
|
|
pname_msg = "You are still {}".format(pname) |
|
|
|
|
|
return render_template( |
|
|
|
|
|
"index.html", |
|
|
|
|
|
upload_form=upload_form, |
|
|
|
|
|
petname_message=pname_msg, |
|
|
|
|
|
petname=pname, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
pname = upload_form.petname.data |
|
|
pname = upload_form.petname.data |
|
|
pname_msg = "You are still {}".format(pname) |
|
|
pname_msg = "You are still {}".format(pname) |
|
|
|
|
|
|
|
|