Commit d5ce0e7d authored by Pierre Dittgen's avatar Pierre Dittgen

Improve column comparison messages

parent 41db51a8
......@@ -129,7 +129,7 @@
</tr>
</thead>
<tbody>
{% for elt in report.table.column_comparison_info %}
{% for elt in report.table.column_comparison_info.table %}
<tr{% if elt[2] == 'ko' %} class="table-danger"{% endif %}>
<td>{{ elt[0] }}</td>
<td>{{ elt[1] }}</td>
......@@ -137,7 +137,12 @@
{% endfor %}
</tbody>
</table>
{% if report.table.column_comparison_info.has_missing %}
<p>Attention : toutes les colonnes attendues doivent être présentes dans le fichier à valider.<p>
{% endif %}
{% if report.table.column_comparison_info.has_case_errors %}
<p>Attention : la casse (minuscules/majuscules) doit être respectée dans les noms de colonne.<p>
{% endif %}
{% endif %}
{% endif %}
......
......@@ -154,11 +154,18 @@ def create_validata_ui_report(validata_core_report, schema):
if column_comparison_needed:
column_comparison_table = []
field_names = [f['name'] for f in schema_fields]
has_case_errors = False
for t in itertools.zip_longest(headers, field_names, fillvalue=''):
status = 'ok' if t[0] == t[1] else 'ko'
if not has_case_errors and status == 'ko' and t[0].lower() == t[1].lower():
has_case_errors = True
column_comparison_table.append((*t, status))
info = {}
info['table'] = column_comparison_table
info['has_missing'] = len(headers) < len(field_names)
info['has_case_errors'] = has_case_errors
report['table']['column_comparison_info'] = info
report['table']['column_comparison_needed'] = column_comparison_needed
report['table']['column_comparison_info'] = column_comparison_table
# Group body errors by row id
rows = []
......
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