Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Validata
Validata UI
Commits
4f37e535
Commit
4f37e535
authored
Oct 03, 2018
by
Pierre Dittgen
Browse files
Display body errors only if no structure errors
parent
8034f2fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
validata_ui_next/templates/validation_report.html
View file @
4f37e535
...
...
@@ -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
validata_ui_next/views.py
View file @
4f37e535
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment