aboutsummaryrefslogtreecommitdiff
path: root/qc_app
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app')
-rw-r--r--qc_app/parse.py13
-rw-r--r--qc_app/templates/errors_display.html8
2 files changed, 15 insertions, 6 deletions
diff --git a/qc_app/parse.py b/qc_app/parse.py
index a017b2c..5d75c37 100644
--- a/qc_app/parse.py
+++ b/qc_app/parse.py
@@ -6,11 +6,12 @@ from redis import Redis
from flask import flash, request, url_for, redirect, Blueprint, render_template
from flask import current_app as app
-from quality_control.errors import InvalidValue
+from quality_control.errors import InvalidValue, DuplicateHeading
from . import jobs
parsebp = Blueprint("parse", __name__)
isinvalidvalue = lambda item: isinstance(item, InvalidValue)
+isduplicateheading = lambda item: isinstance(item, DuplicateHeading)
@parsebp.route("/parse", methods=["GET"])
def parse():
@@ -73,7 +74,9 @@ def parse_status(job_id: str):
if status == "parse-error":
return redirect(url_for("parse.fail", job_id=job_id))
- app.jinja_env.globals.update(isinvalidvalue=isinvalidvalue)
+ app.jinja_env.globals.update(
+ isinvalidvalue=isinvalidvalue,
+ isduplicateheading=isduplicateheading)
return render_template(
"job_progress.html",
job_id = job_id,
@@ -93,8 +96,10 @@ def results(job_id: str):
if job:
filename = job["filename"]
- errors = jsonpickle.decode(job["errors"])
- app.jinja_env.globals.update(isinvalidvalue=isinvalidvalue)
+ errors = jsonpickle.decode(job.get("errors", jsonpickle.encode(tuple())))
+ app.jinja_env.globals.update(
+ isinvalidvalue=isinvalidvalue,
+ isduplicateheading=isduplicateheading)
return render_template(
"parse_results.html",
errors=errors,
diff --git a/qc_app/templates/errors_display.html b/qc_app/templates/errors_display.html
index 0c9a212..39144a9 100644
--- a/qc_app/templates/errors_display.html
+++ b/qc_app/templates/errors_display.html
@@ -22,15 +22,19 @@
<td>
{%if isinvalidvalue(error):%}
{{error.column}}
- {%else: %}
+ {%elif isduplicateheading(error): %}
{{error.columns}}
+ {%else: %}
+ -
{%endif %}
</td>
<td>
{%if isinvalidvalue(error):%}
Invalid Value
- {%else: %}
+ {%elif isduplicateheading(error): %}
Duplicate Header
+ {%else%}
+ Inconsistent Columns
{%endif %}
</td>
<td>{{error["message"]}}</td>