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

Restore filename display in report page

parent a5c15f58
......@@ -66,10 +66,10 @@
<p>
<code>
{% if source.type == 'file' %}
{{ source.filename }}
{% elif source.type == 'url' %}
<a href="{{source.url}}" target="_blank">{{source.filename}}</a>
{% if resource.type == 'file' %}
{{ resource.filename }}
{% elif resource.type == 'url' %}
<a href="{{resource.url}}" target="_blank">{{resource.filename}}</a>
{% endif %}
</code>
({{ report.table.col_count }} colonnes × {{ report.table.row_count }} lignes)
......
......@@ -7,6 +7,7 @@ import json
import logging
from collections import Counter
from datetime import datetime
from pathlib import Path
from urllib.parse import urlencode, urljoin
import frictionless
......@@ -347,6 +348,14 @@ def get_badge_url_and_message(badge):
def validate(schema_instance: SchemaInstance, validata_resource: ValidataResource):
""" 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
header, rows = validata_resource.extract_tabular_data()
rows_count = len(rows)
......@@ -443,7 +452,7 @@ def validate(schema_instance: SchemaInstance, validata_resource: ValidataResourc
schema_info=schema_info,
section_title=schema_instance.section_title,
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"),
)
......
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