Commit 4f37e535 authored by Pierre Dittgen's avatar Pierre Dittgen

Display body errors only if no structure errors

parent 8034f2fb
......@@ -45,8 +45,6 @@
{% if report.table.errors.structure %}
<div>
<h3>Problèmes de structure</h3>
{{ report.table.errors.structure|length }} erreur(s) détectée(s)
{% for err in report.table.errors.structure %}
<div class="alert alert-danger">
{{ err.message | safe}}
......@@ -58,9 +56,12 @@
<!-- row checks -->
{% if report.table.errors.body %}
{% if not report.table.display_body_errors %}
Merci de corriger ce(s) erreur(s) pour visualiser les erreurs de contenu.
{% else %}
<div>
<h3>Problèmes de contenu</h3>
{{ report.table.errors.body|length }} erreur(s) détectée(s)
<div class="table-responsive-sm">
<table class="table-sm table-bordered table-striped table-hover">
<thead class="thead-light">
......@@ -100,18 +101,11 @@
</tbody>
</table>
</div>
{% endif %}
{% endif %}
</div>
<!--
<pre>
{{ report_str | safe }}
</pre>
-->
{% endif %}
{% endblock %}
{% block footer %}
......@@ -127,4 +121,10 @@
})
})
</script>
{#
{{ report.table.errors.structure|length }} erreur(s) détectée(s)
{{ report.table.errors.body|length }} erreur(s) détectée(s)
#}
{% endblock %}
\ No newline at end of file
......@@ -156,26 +156,32 @@ def create_validata_report(goodtables_report, schema):
else:
report['table']['errors']['body'].append(err)
# and group body errors by row id
rows = []
current_row_id = 0
for err in report['table']['errors']['body']:
if not 'row-number' in err:
print('ERR', err)
row_id = err['row-number']
del err['row-number']
del err['context']
if row_id != current_row_id:
current_row_id = row_id
rows.append({'row_id': current_row_id, 'errors': {}})
column_id = err.get('column-number')
if column_id is not None:
del err['column-number']
rows[-1]['errors'][column_id] = err
else:
rows[-1]['errors']['row'] = err
report['table']['errors']['by_rows'] = rows
# If there are structure errors different to invalid-column-delimiter
# => don't display body errors
report['table']['display_body_errors'] = all(err['code'] == 'invalid-column-delimiter'
for err in report['table']['errors']['structure'])
if report['table']['display_body_errors']:
# and group body errors by row id
rows = []
current_row_id = 0
for err in report['table']['errors']['body']:
if not 'row-number' in err:
print('ERR', err)
row_id = err['row-number']
del err['row-number']
del err['context']
if row_id != current_row_id:
current_row_id = row_id
rows.append({'row_id': current_row_id, 'errors': {}})
column_id = err.get('column-number')
if column_id is not None:
del err['column-number']
rows[-1]['errors'][column_id] = err
else:
rows[-1]['errors']['row'] = err
report['table']['errors']['by_rows'] = rows
return report
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment