Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
validata-ui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Validata
validata-ui
Commits
b3c3e09d
Commit
b3c3e09d
authored
Nov 28, 2018
by
Pierre Dittgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Columns table
parent
fdd44444
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
20 deletions
+63
-20
validata_ui/templates/validation_report.html
validata_ui/templates/validation_report.html
+41
-14
validata_ui/views.py
validata_ui/views.py
+22
-6
No files found.
validata_ui/templates/validation_report.html
View file @
b3c3e09d
...
...
@@ -22,9 +22,6 @@
{% endif %}
<h1>
{{ title }}
</h1>
<p
class=
"text"
>
Validation effectuée {{ validation_date }}
</p>
<p
class=
"text alert alert-info hidden-print"
>
Pour relancer la validation,
<a
href=
"#"
onclick=
"location.reload();"
>
rechargez
</a>
la page.
</p>
{% if print_mode %}
</div>
<div
class=
"col-md-7"
>
...
...
@@ -99,18 +96,48 @@
{{ macros.error_statistics(report) }}
<div>
<h3>
Problèmes de structure
</h3>
{% if report.table.errors.structure %}
{% for err in report.table.errors.structure %}
<div
class=
"alert alert-danger"
>
{{ err.message }}
</div>
{% endfor %}
{% else %}
<p
class=
"text"
>
Aucune erreur de structure
</p>
<h3>
Problèmes de structure
</h3>
{% if report.table.errors.structure %}
{# Non-column errors #}
{% for err in report.table.errors.structure %}
{% if not err.in_column_comp %}
{{ err.content | safe }}
{% endif %}
{% endfor %}
{# Column errors #}
{% for err in report.table.errors.structure %}
{% if err.in_column_comp %}
{{ err.content | safe }}
{% endif %}
{% endfor %}
{# Afficher un tableau de comparaison des colonnes #}
{% if report.table.column_comparison_needed %}
<table
class=
"table table-bordered table-sm table-striped"
>
<thead
class=
"thead-light"
>
<tr>
<th
scope=
"col"
>
Colonnes du fichier
</th>
<th
scope=
"col"
>
Champs du schéma
</th>
</tr>
</thead>
<tbody>
{% for elt in report.table.column_comparison_info %}
<tr
{%
if
elt[2] =
=
'
ko
'
%}
class=
"table-danger"
{%
endif
%}
>
<td>
{{ elt[0]}}
</td>
<td>
{{ elt[1]}}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
{% else %}
<p
class=
"text"
>
Aucune erreur de structure
</p>
{% endif %}
{# We do display body errors! #}
{% if report.table.do_display_body_errors %}
...
...
validata_ui/views.py
View file @
b3c3e09d
...
...
@@ -3,6 +3,7 @@
Routes
"""
import
copy
import
itertools
import
json
import
subprocess
import
time
...
...
@@ -90,7 +91,7 @@ def improve_errors(errors):
return
list
(
map
(
improve_err
,
errors
))
def
create_validata_
report
(
goodtables
_report
,
schema
):
def
create_validata_
ui_report
(
validata_core
_report
,
schema
):
""" Creates an error report easier to handle and display in templates:
- only one table
- errors are contextualized
...
...
@@ -99,7 +100,7 @@ def create_validata_report(goodtables_report, schema):
- errors are separated into "structure" and "body"
- error messages are improved
"""
report
=
copy
.
deepcopy
(
goodtables
_report
)
report
=
copy
.
deepcopy
(
validata_core
_report
)
# One table is enough
del
report
[
'table-count'
]
...
...
@@ -144,6 +145,21 @@ def create_validata_report(goodtables_report, schema):
report
[
'table'
][
'do_display_body_errors'
]
=
len
(
structure_errors
)
==
0
or
\
all
(
err
[
'code'
]
==
'invalid-column-delimiter'
for
err
in
structure_errors
)
# Checks if a column comparison is needed
header_errors
=
(
'missing-headers'
,
'extra-headers'
,
'wrong-headers-order'
)
structure_errors
=
[{
**
err
,
'in_column_comp'
:
err
[
'code'
]
in
header_errors
}
for
err
in
structure_errors
]
report
[
'table'
][
'errors'
][
'structure'
]
=
structure_errors
column_comparison_needed
=
any
(
err
[
'in_column_comp'
]
==
True
for
err
in
structure_errors
)
column_comparison_table
=
[]
if
column_comparison_needed
:
column_comparison_table
=
[]
field_names
=
[
f
[
'name'
]
for
f
in
schema_fields
]
for
t
in
itertools
.
zip_longest
(
headers
,
field_names
,
fillvalue
=
''
):
status
=
'ok'
if
t
[
0
]
==
t
[
1
]
else
'ko'
column_comparison_table
.
append
((
*
t
,
status
))
report
[
'table'
][
'column_comparison_needed'
]
=
column_comparison_needed
report
[
'table'
][
'column_comparison_info'
]
=
column_comparison_table
# Group body errors by row id
rows
=
[]
current_row_id
=
0
...
...
@@ -181,7 +197,7 @@ def validate(schema_code, source: ValidataSource):
""" Validate source and display report """
try
:
goodtables
_report
=
ValidatorHelper
.
validate
(
validata_core
_report
=
ValidatorHelper
.
validate
(
schema_code
=
schema_code
,
force_strings
=
True
,
**
source
.
get_tabulator_params
(),
...
...
@@ -193,11 +209,11 @@ def validate(schema_code, source: ValidataSource):
source_data
=
extract_source_data
(
source
)
# handle report date
date_str
=
goodtables
_report
[
'date'
]
date_str
=
validata_core
_report
[
'date'
]
report_date
=
datetime
.
strptime
(
date_str
[:
date_str
.
find
(
'.'
)],
'%Y-%m-%dT%H:%M:%S'
)
# Enhance
goodtables
_report
validata_report
=
create_validata_
report
(
goodtables
_report
,
ValidatorHelper
.
schema
(
schema_code
).
descriptor
)
# Enhance
validata_core
_report
validata_report
=
create_validata_
ui_report
(
validata_core
_report
,
ValidatorHelper
.
schema
(
schema_code
).
descriptor
)
# Display report to the user
val_info
=
ValidatorHelper
.
schema_info
(
schema_code
)
...
...
Write
Preview
Markdown
is supported
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