Commit 1410a3d5 authored by Christophe Benz's avatar Christophe Benz

Display validation date in user locale

parent d5ce0e7d
......@@ -23,6 +23,8 @@ setup(
packages=['validata_ui'],
include_package_data=True,
install_requires=[
'backports-datetime-fromisoformat',
'commonmark',
'ezodf',
'flask',
......
......@@ -13,6 +13,7 @@ from operator import itemgetter
from pathlib import Path
from urllib.parse import quote_plus
from backports.datetime_fromisoformat import MonkeyPatch
from commonmark import commonmark
from flask import make_response, redirect, render_template, request, url_for
......@@ -24,6 +25,8 @@ from validata_ui.ui_util import flash_error, flash_warning
from validata_ui.validata_util import ValidataSource
from validata_ui.validate_helper import ValidatorHelper
MonkeyPatch.patch_fromisoformat()
def extract_source_data(source: ValidataSource, preview_rows_nb=5):
""" Computes table preview """
......@@ -216,8 +219,7 @@ def validate(schema_code, source: ValidataSource):
source_data = extract_source_data(source)
# handle report date
date_str = validata_core_report['date']
report_date = datetime.strptime(date_str[:date_str.find('.')], '%Y-%m-%dT%H:%M:%S')
report_datetime = datetime.fromisoformat(validata_core_report['date']).astimezone()
# Enhance validata_core_report
validata_report = create_validata_ui_report(validata_core_report, ValidatorHelper.schema(schema_code).descriptor)
......@@ -226,7 +228,7 @@ def validate(schema_code, source: ValidataSource):
val_info = ValidatorHelper.schema_info(schema_code)
return render_template('validation_report.html', title='Rapport de validation',
val_info=ValidatorHelper.schema_info(schema_code), report=validata_report,
validation_date=report_date.strftime('le %d/%m/%Y à %Hh%M'),
validation_date=report_datetime.strftime('le %d/%m/%Y à %Hh%M'),
source=source, source_type=source.type, source_data=source_data,
print_mode=request.args.get('print', 'false') == 'true',
report_str=json.dumps(validata_report, sort_keys=True, indent=2),
......
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