Commit c561e788 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Restore filename display in report page

parent a5c15f58
...@@ -66,10 +66,10 @@ ...@@ -66,10 +66,10 @@
<p> <p>
<code> <code>
{% if source.type == 'file' %} {% if resource.type == 'file' %}
{{ source.filename }} {{ resource.filename }}
{% elif source.type == 'url' %} {% elif resource.type == 'url' %}
<a href="{{source.url}}" target="_blank">{{source.filename}}</a> <a href="{{resource.url}}" target="_blank">{{resource.filename}}</a>
{% endif %} {% endif %}
</code> </code>
({{ report.table.col_count }} colonnes × {{ report.table.row_count }} lignes) ({{ report.table.col_count }} colonnes × {{ report.table.row_count }} lignes)
......
...@@ -7,6 +7,7 @@ import json ...@@ -7,6 +7,7 @@ import json
import logging import logging
from collections import Counter from collections import Counter
from datetime import datetime from datetime import datetime
from pathlib import Path
from urllib.parse import urlencode, urljoin from urllib.parse import urlencode, urljoin
import frictionless import frictionless
...@@ -347,6 +348,14 @@ def get_badge_url_and_message(badge): ...@@ -347,6 +348,14 @@ def get_badge_url_and_message(badge):
def validate(schema_instance: SchemaInstance, validata_resource: ValidataResource): def validate(schema_instance: SchemaInstance, validata_resource: ValidataResource):
""" Validate source and display report """ """ Validate source and display report """
def compute_resource_info(resource: ValidataResource):
source = resource.get_source()
return {
"type": "url" if source.startswith("http") else "file",
"url": source,
"filename": Path(source).name,
}
# Parse source data once # Parse source data once
header, rows = validata_resource.extract_tabular_data() header, rows = validata_resource.extract_tabular_data()
rows_count = len(rows) rows_count = len(rows)
...@@ -443,7 +452,7 @@ def validate(schema_instance: SchemaInstance, validata_resource: ValidataResourc ...@@ -443,7 +452,7 @@ def validate(schema_instance: SchemaInstance, validata_resource: ValidataResourc
schema_info=schema_info, schema_info=schema_info,
section_title=schema_instance.section_title, section_title=schema_instance.section_title,
source_data=build_template_source_data(header, rows), source_data=build_template_source_data(header, rows),
source=validata_resource, resource=compute_resource_info(validata_resource),
validation_date=report_datetime.strftime("le %d/%m/%Y à %Hh%M"), validation_date=report_datetime.strftime("le %d/%m/%Y à %Hh%M"),
) )
......
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