Commit 66943441 authored by Pierre Dittgen's avatar Pierre Dittgen

Use config.json

parent a5effda7
...@@ -8,4 +8,7 @@ BADGE_CONFIG_URL="https://git.opendatafrance.net/validata/validata-badge/raw/mas ...@@ -8,4 +8,7 @@ BADGE_CONFIG_URL="https://git.opendatafrance.net/validata/validata-badge/raw/mas
SHIELDS_IO_BASE_URL="https://img.shields.io/" SHIELDS_IO_BASE_URL="https://img.shields.io/"
# Validata API endpoint # Validata API endpoint
API_VALIDATE_ENDPOINT=http://127.0.0.1:5600/validate API_VALIDATE_ENDPOINT=http://127.0.0.1:5600/validate
\ No newline at end of file
# UI config file path
UI_CONFIG_FILE=config.json
\ No newline at end of file
[
{
"code": "scdl",
"title": "Validateurs SCDL",
"catalog": [
{
"code": "scdl-adresses",
"title": "Adresses locales",
"description": "Liste des adresses locales d'une collectivité",
"schema_url": "https://git.opendatafrance.net/scdl/adresses/raw/v1.1.3/schema.json",
"doc_url": "https://scdl.opendatafrance.net/docs/schemas/scdl-adresses.html"
},
{
"code": "scdl-catalogue",
"title": "Catalogue simplifié",
"description": "Liste des jeux de données publiés en open data par une collectivité",
"schema_url": "https://git.opendatafrance.net/scdl/catalogue/raw/v0.1.1/schema.json",
"doc_url": "https://scdl.opendatafrance.net/docs/schemas/scdl-catalogue.html"
},
{
"code": "scdl-deliberations",
"title": "Délibérations",
"description": "Liste des délibérations adoptées par une assemblée locale",
"schema_url": "https://git.opendatafrance.net/scdl/deliberations/raw/v2.1.2/schema.json",
"doc_url": "https://scdl.opendatafrance.net/docs/schemas/scdl-deliberations.html"
},
{
"code": "scdl-equipements",
"title": "Equipements",
"description": "Liste des équipements collectifs publics d'une collectivité",
"schema_url": "https://git.opendatafrance.net/scdl/equipements/raw/v0.1.0/schema.json",
"doc_url": "https://scdl.opendatafrance.net/docs/schemas/scdl-equipements.html"
},
{
"code": "scdl-irve",
"title": "Infrastructures de recharge de véhicule électrique",
"description": "Liste des infrastructures de recharge de véhicules électriques d'une collectivité",
"schema_url": "https://raw.githubusercontent.com/OpenDataFrance/schema.data.gouv.fr/master/irve/schema.json",
"doc_url": "https://scdl.opendatafrance.net/docs/schemas/scdl-irve.html"
},
{
"code": "scdl-marches-publics",
"title": "Marchés publics",
"description": "Liste des marchés publics attribués par une collectivité",
"schema_url": "https://git.opendatafrance.net/scdl/marches-publics/raw/v2.0.0/schema.json",
"doc_url": "https://scdl.opendatafrance.net/docs/schemas/scdl-marches-publics.html"
},
{
"code": "scdl-prenoms",
"title": "Prénoms des nouveaux-nés",
"description": "Liste des prénoms des nouveaux-nés déclarés à l'état-civil",
"schema_url": "https://github.com/OpenDataFrance/liste-prenoms-nouveaux-nes/raw/v1.1.3/schema.json",
"doc_url": "https://scdl.opendatafrance.net/docs/schemas/scdl-prenoms.html"
},
{
"code": "scdl-subventions",
"title": "Subventions",
"description": "Liste des subventions publiques attribuées par une collectivité",
"schema_url": "https://git.opendatafrance.net/scdl/subventions/raw/v2.0.0/schema.json",
"doc_url": "https://scdl.opendatafrance.net/docs/schemas/scdl-subventions.html"
}
]
},
{
"code": "external",
"title": "Validateurs externes",
"catalog": [
{
"code": "inspire",
"type": "external",
"title": "INSPIRE",
"description": "proposé par la Commission Européenne pour tester des ressources géographiques (données, services ou métadonnées)",
"website": "http://inspire-sandbox.jrc.ec.europa.eu/validator/"
},
{
"code": "bal",
"type": "external",
"title": "BAL",
"description": "proposé par la mission Etalab pour tester des données Adresse produites localement (format BAL 1.1)",
"website": "https://adresse.data.gouv.fr/bases-locales/validateur"
},
{
"code": "cvdtc",
"type": "external",
"title": "CVDTC",
"description": "proposé par l'AFIMB dans le cadre du projet Chouette pour tester des données de transport collectif (GTFS ou NEPTUNE)",
"website": "http://www.conversion-validation-donnees-tc.org/"
}
]
}
]
\ No newline at end of file
import json
import os import os
from pathlib import Path from pathlib import Path
from urllib.parse import quote_plus from urllib.parse import quote_plus
...@@ -9,7 +10,12 @@ import jinja2 ...@@ -9,7 +10,12 @@ import jinja2
from . import config from . import config
# TODO: load config.toml # TODO: load config.toml
ui_config = json.load(config.UI_CONFIG_FILE.open('rt', encoding='utf-8')) if config.UI_CONFIG_FILE else []
schema_info_map = {}
for section in ui_config:
for val in section['catalog']:
if 'schema_url' in val:
schema_info_map[val['schema_url']] = val
# Flask things # Flask things
app = flask.Flask(__name__) app = flask.Flask(__name__)
......
import logging import logging
import os import os
from pathlib import Path
import requests import requests
import toml import toml
...@@ -31,3 +32,7 @@ else: ...@@ -31,3 +32,7 @@ else:
SHIELDS_IO_BASE_URL = os.environ.get("SHIELDS_IO_BASE_URL") or None SHIELDS_IO_BASE_URL = os.environ.get("SHIELDS_IO_BASE_URL") or None
if SHIELDS_IO_BASE_URL and not SHIELDS_IO_BASE_URL.endswith('/'): if SHIELDS_IO_BASE_URL and not SHIELDS_IO_BASE_URL.endswith('/'):
SHIELDS_IO_BASE_URL += '/' SHIELDS_IO_BASE_URL += '/'
UI_CONFIG_FILE = os.environ.get("UI_CONFIG_FILE") or None
if UI_CONFIG_FILE:
UI_CONFIG_FILE = Path(UI_CONFIG_FILE)
...@@ -4,50 +4,61 @@ block head %} ...@@ -4,50 +4,61 @@ block head %}
{% endblock %} {% block content %} {% endblock %} {% block content %}
<h1 class="my-4">Validez vos jeux de données</h1> <h1 class="my-4">Validez vos jeux de données</h1>
<h2>Validateurs <span abbr="Socle commun des données locales">SCDL</span></h2> {% for section in config %}
<h2>{{section.title}}</h2>
<div class="row my-4"> <div class="row my-4">
{% for val in validators %} {% for val in section.catalog %}
<div class="col-sm-4 col-md-3 mb-4"> {% if val.website %}
<div class="card text-center h-100"> <div class="col-sm-4 col-md-3 mb-4">
<div class="card-body d-flex flex-column"> <div class="card text-center h-100">
<h4 class="card-title">{{ val.title }}</h4> <div class="card-body d-flex flex-column">
<p class="card-text">{{ val.description }}</p> <h4 class="card-title">{{ val.title }}</h4>
<a <p class="card-text">{{ val.description }}</p>
href="{{ url_for('scdl_validator', val_code=val.code) }}" <a
class="btn btn-primary mt-auto" href="{{ val.website }}" target="_blank"
>Choisir</a class="btn btn-primary mt-auto"
> >Voir
<i class="fas fa-external-link-alt ml-1"></i>
</a
>
</div>
</div> </div>
</div> </div>
</div> {% else %}
{% endfor %} <div class="col-sm-4 col-md-3 mb-4">
</div> <div class="card text-center h-100">
<div class="card-body d-flex flex-column">
<h2>Validateurs externes</h2> <h4 class="card-title">{{ val.title }}</h4>
<p class="card-text">{{ val.description }}</p>
<div class="row my-4"> <a
{% for val in external_validators %} href="{{ url_for('custom_validator') }}?schema={{val.schema_url|urlencode}}"
<div class="col-sm-4 col-md-3 mb-4"> class="btn btn-primary mt-auto"
<div class="card text-center h-100"> >Choisir</a
<div class="card-body d-flex flex-column"> >
<h4 class="card-title">{{ val.title }}</h4> </div>
<p class="card-text">{{ val.description }}</p>
<a href="{{ val.url }}" class="btn btn-primary mt-auto" target="_blank">
Voir
<i class="fas fa-external-link-alt ml-1"></i>
</a>
</div> </div>
</div> </div>
</div> {% endif %}
{% endfor %} {% endfor %}
</div> </div>
{% endfor %}
<h2>Validateur personnalisé</h2> <h2>Validateur personnalisé</h2>
<p> <p>
<a href="{{ url_for('custom_validator') }}" <form action="{{ url_for('custom_validator') }}" method="GET">
>Choisissez le schéma qui vous convient</a <div class="form-group">
> <label for="schema">Indiquez l'URL du schema de validation</label>
<input
name="schema"
type="url"
class="form-control"
id="schema"
aria-describedby="urlHelp"
placeholder="https://..."
/>
</div>
<input type="submit" value="Continuer" />
</form>
</p> </p>
{% endblock %} {% endblock %}
<h5 class="card-title">
Schéma
{% if val_info.title %}
« {{ val_info.title }} »
{% else %}
personnalisé
{% endif %}
{#
<span class="badge badge-primary">{{ val_info.version }}</span>
#}
</h5>
{% if val_info.description %}
<h6 class="card-subtitle mb-2 text-muted">{{ val_info.description }}</h6>
{% endif %}
{% if val_info.author or val_info.contributor %}
<p>
{% if val_info.author %}
Auteur : {{ val_info.author }}
{% endif %}
{% if val_info.contributor %}
<br />Contributeur(s) : {{ val_info.contributor }}
{% endif %}
</p>
{% endif %}
<p>
{% if val_info.doc_url %}
<a href="{{ val_info.doc_url }}" target="_blank" class="card-link">Documentation</a>
{% else %}
<a href="{{ schema_url }}" target="_blank" class="card-link">{{ schema_url }}</a>
{% endif %}
</p>
...@@ -2,145 +2,84 @@ ...@@ -2,145 +2,84 @@
block head %} block head %}
{{ super() }} {{ super() }}
{% endblock %} {% block content %} {% endblock %} {% block content %}
<h1 class="my-4">Formulaire de validation</h1> <h1 class="my-4">{{ title }}</h1>
{#
{% set cols_my_classes = 'my-md-0 my-4' %} {% set cols_my_classes = 'my-md-0 my-4' %}
<div class="row"> <div class="row">
<div class="col-md-4 {{ cols_my_classes }}"> <div class="col-md-4 {{ cols_my_classes }}">
<div class="card bg-faded"> <div class="card bg-faded">
<div class="card-body"> <div class="card-body">
<h5 class="card-title"> {% include 'schema_info_part.html' %}
Schéma {{ val_info.code }} </div>
{% if val_info.version %} </div>
<span class="badge badge-primary">{{ val_info.version }}</span>
{% else %}
<span
class="badge badge-primary"
title="Schéma en cours de développement"
>dev</span
>
{% endif %}
</h5>
<h6 class="card-subtitle mb-2 text-muted">
{{ val_info.description }}
</h6>
{% if val_info.author or val_info.contributor %}
<p class="text">
{% if val_info.author %} Auteur : {{ val_info.author }}
{% endif %} {% if val_info.contributor %}
<br />Contributeur(s) : {{ val_info.contributor }}
{% endif %}
</p>
{% endif %}
</div>
</div> </div>
</div> <div class="col-md-8 {{ cols_my_classes }}">
</div> <h2>Outil de validation</h2>
#} <!-- Tab validator -->
<p class="text">Validez ici le fichier de votre choix</p>
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="file-tab" data-toggle="tab" href="#file" role="tab" aria-controls="file"
aria-selected="true">Fichier</a>
</li>
<li class="nav-item">
<a class="nav-link" id="url-tab" data-toggle="tab" href="#url" role="tab" aria-controls="url"
aria-selected="false">URL</a>
</li>
{#
<li class="nav-item">
<a class="nav-link" id="examples-tab" data-toggle="tab" href="#example" role="tab" aria-controls="examples"
aria-selected="false">Exemples</a>
</li>
#}
</ul>
{% set padding_class = 'p-3' %}
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active {{ padding_class }}" id="file" role="tabpanel" aria-labelledby="file-tab">
<form method="POST" enctype="multipart/form-data">
<input type="hidden" name="input" value="file" />
<input type="hidden" name="schema" value="{{ schema_url }}" />
<div class="form-group">
<label for="file">Choisissez un fichier tabulaire à valider (.xlsx, .xls, .ods, .csv, .tsv,
etc.)</label>
<input type="file" class="form-control-file" name="file" id="file" accept=".csv, .xls, .xlsx, .ods" />
</div>
<button type="submit" class="btn btn-primary">Valider</button>
</form>
</div>
<div class="tab-pane fade {{ padding_class }}" id="url" role="tabpanel" aria-labelledby="url-tab">
<form method="GET">
<input type="hidden" name="input" value="url" />
<input type="hidden" name="schema" value="{{ schema_url }}" />
<div class="form-group">
<label for="url">Indiquez l'URL de la table à valider</label>
<input name="url" type="url" class="form-control" id="url" aria-describedby="urlHelp"
placeholder="https://..." />
<div class="row"> </div>
<div class="col-md-8 {{ cols_my_classes }}"> <button type="submit" class="btn btn-primary">Valider</button>
<!-- Tab validator --> </form>
{# </div>
<p class="text">Validez ici le fichier de votre choix</p> {#
<ul class="nav nav-tabs" id="myTab" role="tablist"> <div class="tab-pane fade {{ padding_class }}" id="example" role="tabpanel" aria-labelledby="examples-tab">
<li class="nav-item"> <form method="GET">
<a <input type="hidden" name="input" value="example" />
class="nav-link active" <div class="form-group">
id="file-tab" <label for="url">Choisissez l'exemple à valider</label>
data-toggle="tab" <select name="url" id="example" class="form-control">
href="#file" <option value="">...</option>
role="tab" {% for example in val_info.examples %}
aria-controls="file" <option value="{{ example.url }}">{{ example.name }}</option>
aria-selected="true" {% endfor %}
>Fichier</a </select>
> </div>
</li> <button type="submit" class="btn btn-primary">Valider</button>
<li class="nav-item"> </form>
<a </div>
class="nav-link" #}
id="url-tab" </div>
data-toggle="tab"
href="#url"
role="tab"
aria-controls="url"
aria-selected="false"
>URL</a
>
</li>
</ul>
{% set padding_class = 'p-3' %}
<div class="tab-content" id="myTabContent">
<div
class="tab-pane fade show active {{ padding_class }}"
id="file"
role="tabpanel"
aria-labelledby="file-tab"
>#}
<h2>Valider un fichier</h2>
<div>
<form method="POST" enctype="multipart/form-data">
<input type="hidden" name="input" value="file" />
<div class="form-group">
<label for="schema">Indiquez l'URL du schema de validation</label>
<input
name="schema"
type="url"
class="form-control"
aria-describedby="urlHelp"
placeholder="https://..."
/>
<div class="form-group">
<label for="file"
>Choisissez un fichier tabulaire à valider (.xlsx, .xls, .ods,
.csv, .tsv, etc.)</label
>
<input
type="file"
class="form-control-file"
name="file"
id="file"
accept=".csv, .xls, .xlsx, .ods"
/>
</div>
<button type="submit" class="btn btn-primary">Valider</button>
</form>
</div>
<h2>Valider une URL</h2>
<div
class="tab-pane {{ padding_class }}"
id="url"
role="tabpanel"
aria-labelledby="url-tab"
>
<form method="GET">
<input type="hidden" name="input" value="url" />
<div class="form-group">
<label for="schema">Indiquez l'URL du schema de validation</label>
<input
name="schema"
type="url"
class="form-control"
id="schema"
aria-describedby="urlHelp"
placeholder="https://..."
/>
<div class="form-group">
<label for="url">Indiquez l'URL de la table à valider</label>
<input
name="url"
type="url"
class="form-control"
id="url"
aria-describedby="urlHelp"
placeholder="https://..."
/>
</div>
<button type="submit" class="btn btn-primary">Valider</button>
</form>
</div>
</div> </div>
</div>
</div> </div>
{% endblock %} {% block footer %} {% endblock %} {% endblock %} {% block footer %} {% endblock %}
...@@ -45,25 +45,8 @@ ...@@ -45,25 +45,8 @@
<div class="row"> <div class="row">
<div class="col-md-{% if print_mode %}12{% else %}5{% endif %} my-4"> <div class="col-md-{% if print_mode %}12{% else %}5{% endif %} my-4">
<div class="card bg-faded"> <div class="card bg-faded">
<div class="card-body"> <div class="card-body">
<h5 class="card-title"> {% include 'schema_info_part.html' %}
Schéma
<span class="badge badge-primary">{{ val_info.version }}</span>
</h5>
<h6 class="card-subtitle mb-2 text-muted">{{ val_info.description }}</h6>
{% if val_info.author or val_info.contributor %}
<p>
{% if val_info.author %}
Auteur : {{ val_info.author }}
{% endif %}
{% if val_info.contributor %}
<br />Contributeur(s) : {{ val_info.contributor }}
{% endif %}
</p>
{% endif %}
<p>
<a href="{{ schema_url }}" target="_blank" class="card-link">{{ schema_url }}</a>
</p>
<hr /> <hr />
<div> <div>
<h5 class="card-title"> <h5 class="card-title">
......
...@@ -22,7 +22,7 @@ from validata_core.loaders import custom_loaders ...@@ -22,7 +22,7 @@ from validata_core.loaders import custom_loaders
import tabulator import tabulator
from . import app, config from . import app, config, ui_config, schema_info_map
from .ui_util import flash_error, flash_warning from .ui_util import flash_error, flash_warning
from .validata_util import ValidataSource from .validata_util import ValidataSource
...@@ -298,8 +298,10 @@ def validate(schema_url, source: ValidataSource): ...@@ -298,8 +298,10 @@ def validate(schema_url, source: ValidataSource):
validata_report = create_validata_ui_report(validata_core_report, schema_dict) validata_report = create_validata_ui_report(validata_core_report, schema_dict)
# Display report to the user # Display report to the user
validator_form_url = url_for("custom_validator")+'?schema='+quote_plus(schema_url)
val_info, validator_title = compute_validator_info(schema_url)
return render_template('validation_report.html', title='Rapport de validation', return render_template('validation_report.html', title='Rapport de validation',
val_info={}, report=validata_report, val_info=val_info, report=validata_report,
schema_url=schema_url, schema_url=schema_url,
validation_date=report_datetime.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, source=source, source_type=source.type, source_data=source_data,
...@@ -307,7 +309,7 @@ def validate(schema_url, source: ValidataSource): ...@@ -307,7 +309,7 @@ def validate(schema_url, source: ValidataSource):
badge_url=badge_url, badge_msg=badge_msg, badge_url=badge_url, badge_msg=badge_msg,
report_str=json.dumps(validata_report, sort_keys=True, indent=2), report_str=json.dumps(validata_report, sort_keys=True, indent=2),
breadcrumbs=[{'url': url_for('home'), 'title': 'Accueil'}, breadcrumbs=[{'url': url_for('home'), 'title': 'Accueil'},
{'url': url_for('custom_validator'), 'title': 'Schéma personnalisé'}, {'url': validator_form_url, 'title': validator_title},
]) ])
...@@ -325,25 +327,8 @@ def bytes_data(f): ...@@ -325,25 +327,8 @@ def bytes_data(f):
@app.route('/') @app.route('/')
def home(): def home():
""" Home page """ """ Home page """
external_validators = [
{
"title": "INSPIRE",
"description": "proposé par la Commission Européenne pour tester des ressources géographiques (données, services ou métadonnées)",
"url": "http://inspire-sandbox.jrc.ec.europa.eu/validator/"
},
{
"title": "BAL",
"description": "proposé par la mission Etalab pour tester des données Adresse produites localement (format BAL 1.1)",
"url": "https://adresse.data.gouv.fr/bases-locales/validateur"
},
{
"title": "CVDTC",
"description": "proposé par l'AFIMB dans le cadre du projet Chouette pour tester des données de transport collectif (GTFS ou NEPTUNE)",
"url": "http://www.conversion-validation-donnees-tc.org/"
},
]
flash_warning('Ce service est fourni en mode beta - certains problèmes peuvent subsister - nous mettons tout en œuvre pour améliorer son fonctionnement en continu.') flash_warning('Ce service est fourni en mode beta - certains problèmes peuvent subsister - nous mettons tout en œuvre pour améliorer son fonctionnement en continu.')
return render_template('home.html', title='Accueil', validators=[], external_validators=external_validators) return render_template('home.html', title='Accueil', config=ui_config)
@app.route('/validators') @app.route('/validators')
...@@ -394,6 +379,16 @@ def pdf_report(): ...@@ -394,6 +379,16 @@ def pdf_report():
return response return response
def compute_validator_info(schema_url):
"""Factor code for validator form page"""
val_info = None
title = "Schéma personnalisé"
if schema_url in schema_info_map:
val_info = schema_info_map.get(schema_url)
title = "Schéma « {} »".format(val_info['title'])
return val_info, title
@app.route('/validators/form', methods=['GET', 'POST']) @app.route('/validators/form', methods=['GET', 'POST'])
def custom_validator(): def custom_validator():
""" Validator page """ """ Validator page """
...@@ -402,54 +397,61 @@ def custom_validator(): ...@@ -402,54 +397,61 @@ def custom_validator():
flash_error("URL de connexion à l'API non indiquée :-(") flash_error("URL de connexion à l'API non indiquée :-(")
return redirect(url_for('home')) return redirect(url_for('home'))
def validation_form_url(schema_url):
"""Computes validation form url with schema URL parameter"""
return "{}?schema={}".format(url_for('custom_validator'), quote_plus(schema_url))
if request.method == 'GET': if request.method == 'GET':
input_param = request.args.get('input') input_param = request.args.get('input')
url_param = request.args.get("url") url_param = request.args.get("url")
schema_param = request.args.get("schema") schema_param = request.args.get("schema")
if schema_param is None or schema_param == '':
flash_error("Vous n'avez pas indiqué d'url de schéma")
return redirect(url_for('home'))
# First form display # First form display
if input_param is None: if input_param is None:
return render_template('validation_form.html', title="Formulaire de validation",
val_info=None, val_info, title = compute_validator_info(schema_param)
return render_template('validation_form.html', title=title,
val_info=val_info, schema_url=schema_param,
breadcrumbs=[{'url': url_for('home'), 'title': 'Accueil'}, ]) breadcrumbs=[{'url': url_for('home'), 'title': 'Accueil'}, ])
# Process URL # Process URL
else: else:
if url_param is None or url_param == '': if url_param is None or url_param == '':
flash_error("Vous n'avez pas indiqué d'url à valider") flash_error("Vous n'avez pas indiqué d'url à valider")
return redirect(url_for('custom_validator')) return redirect(validation_form_url(schema_param))
if schema_param is None or schema_param == '':
flash_error("Vous n'avez pas indiqué d'url de schéma")
return redirect(url_for('custom_validator'))
try: try:
return validate(schema_param, ValidataSource('url', url_param, url_param)) return validate(schema_param, ValidataSource('url', url_param, url_param))
except tabulator.exceptions.FormatError as e: except tabulator.exceptions.FormatError as e:
flash_error('Erreur : Format de ressource non supporté') flash_error('Erreur : Format de ressource non supporté')
log.info(e) log.info(e)
return redirect(url_for('custom_validator')) return redirect(validation_form_url(schema_param))
except tabulator.exceptions.HTTPError as e: except tabulator.exceptions.HTTPError as e:
flash_error('Erreur : impossible d\'accéder au fichier source en ligne') flash_error('Erreur : impossible d\'accéder au fichier source en ligne')
log.info(e) log.info(e)
return redirect(url_for('custom_validator')) return redirect(validation_form_url(schema_param))
else: # POST else: # POST
input_param = request.form.get('input')
if input_param is None:
flash_error('Aucun fichier à valider')
return redirect(url_for('custom_validator'))
schema_param = request.form.get('schema') schema_param = request.form.get('schema')
if schema_param is None: if schema_param is None:
flash_error('Aucun schéma défini') flash_error('Aucun schéma défini')
return redirect(url_for('custom_validator')) return redirect(url_for('home'))
input_param = request.form.get('input')
if input_param is None:
flash_error("Vous n'avez pas indiqué de fichier à valider")
return redirect(validation_form_url(schema_param))
# File validation # File validation
if input_param == 'file': if input_param == 'file':
f = request.files.get('file') f = request.files.get('file')
if f is None: if f is None:
flash_warning("Vous n'avez pas indiqué de fichier à valider") flash_warning("Vous n'avez pas indiqué de fichier à valider")
return redirect(url_for('custom_validator')) return redirect(validation_form_url(schema_param))
b_content = bytes_data(f) b_content = bytes_data(f)
return validate(schema_param, ValidataSource('file', f.filename, b_content)) return validate(schema_param, ValidataSource('file', f.filename, b_content))
......