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
c7446b8e
Commit
c7446b8e
authored
Oct 02, 2018
by
Pierre Dittgen
Browse files
Display column title
parent
f6558b1e
Changes
3
Hide whitespace changes
Inline
Side-by-side
validata_ui_next/templates/validation_report.html
View file @
c7446b8e
...
...
@@ -64,8 +64,8 @@
<table
class=
"table-sm table-bordered"
>
<thead
class=
"thead-light"
>
<th
scope=
"col"
>
1
</th>
{% for h in report
['
table
']['
headers
']
%}
<th
scope=
"col"
>
{{ h }}
</th>
{% for h in report
.
table
.
headers %}
<th
scope=
"col"
data-toggle=
"tooltip"
title=
"{{ report.table.headers_title[loop.index - 1]}}"
>
{{ h }}
</th>
{% endfor %}
</thead>
<tbody>
...
...
@@ -126,4 +126,4 @@
})
})
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
validata_ui_next/validate_helper.py
View file @
c7446b8e
...
...
@@ -75,6 +75,13 @@ class ValidatorHelper:
return
{
**
d1
,
'code'
:
schema_code
,
**
d2
}
@
classmethod
def
schema_fields
(
cls
,
schema_code
):
""" Return schema fields from schema code """
if
not
cls
.
schema_exist
(
schema_code
):
return
None
return
cls
.
schema_dict
[
schema_code
][
'schema'
][
'fields'
]
@
classmethod
def
schema_info_list
(
cls
):
""" Computes and return schema info list """
...
...
validata_ui_next/views.py
View file @
c7446b8e
...
...
@@ -122,7 +122,7 @@ def contextualize(errors):
return
[{
**
err
,
'context'
:
ERR_CODE_TO_CONTEXT
.
get
(
err
[
'code'
],
'body'
)}
for
err
in
errors
]
def
create_validata_report
(
goodtables_report
):
def
create_validata_report
(
goodtables_report
,
schema_fields
=
[]
):
""" Creates an error report easier to handle and display in templates:
- only one table
- errors are contextualized
...
...
@@ -144,8 +144,13 @@ def create_validata_report(goodtables_report):
# use _ instead of - to ease information picking in jinja2 template
report
[
'table'
][
'row_count'
]
=
report
[
'table'
][
'row-count'
]
# Shortcut
report
[
'table'
][
'col_count'
]
=
len
(
report
[
'table'
].
get
(
'headers'
,
[]))
# Handy col_count info
headers
=
report
[
'table'
].
get
(
'headers'
,
[])
report
[
'table'
][
'col_count'
]
=
len
(
headers
)
# Headers title
fields_dict
=
{
f
[
'name'
]:
f
[
'title'
]
for
f
in
schema_fields
}
report
[
'table'
][
'headers_title'
]
=
[
fields_dict
.
get
(
h
,
'?? colonne inconnue dans le schéma ??'
)
for
h
in
headers
]
# Add context to errors
errors
=
contextualize
(
report
[
'table'
][
'errors'
])
...
...
@@ -195,7 +200,7 @@ def validate(schema_code, source: ValidataSource):
source_data
=
extract_source_data
(
source
)
validata_report
=
create_validata_report
(
goodtables_report
)
validata_report
=
create_validata_report
(
goodtables_report
,
ValidatorHelper
.
schema_fields
(
schema_code
)
)
# return jsonify(validata_report)
...
...
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