Commit 0c777a52 authored by Pierre Dittgen's avatar Pierre Dittgen

Remove unused code

parent f21f8a99
{% extends "base_template.html" %}
{% block title %}{{ title }}{% endblock %}
{% block head %}
{{ super() }}
{% endblock %}
{% block content %}
<h1 class="my-4">Schéma « {{ title }} »</h1>
{% set cols_my_classes = 'my-md-0 my-4' %}
<div class="row">
<div class="col-md-4 {{ cols_my_classes }}">
<div class="card bg-faded">
<div class="card-body">
<h5 class="card-title">
Schéma {{ val_info.code }}
{% if val_info.version %}
<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 %}
<a href="{{ val_info.doc_url }}" target="_blank" class="card-link">Documentation</a>
</div>
</div>
</div>
<div class="col-md-8 {{ cols_my_classes }}">
<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" />
<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" />
<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 class="tab-pane fade {{ padding_class }}" id="example" role="tabpanel" aria-labelledby="examples-tab">
<form method="GET">
<input type="hidden" name="input" value="example" />
<div class="form-group">
<label for="url">Choisissez l'exemple à valider</label>
<select name="url" id="example" class="form-control">
<option value="">...</option>
{% for example in val_info.examples %}
<option value="{{ example.url }}">{{ example.name }}</option>
{% endfor %}
</select>
</div>
<button type="submit" class="btn btn-primary">Valider</button>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block footer %}
{% endblock %}
\ No newline at end of file
......@@ -2,7 +2,7 @@
block head %}
{{ super() }}
{% endblock %} {% block content %}
<h1 class="my-4">Validateur personnalisé</h1>
<h1 class="my-4">Formulaire de validation</h1>
{#
{% set cols_my_classes = 'my-md-0 my-4' %}
<div class="row">
......
......@@ -389,7 +389,7 @@ def pdf_report():
return response
@app.route('/validators/custom', methods=['GET', 'POST'])
@app.route('/validators/form', methods=['GET', 'POST'])
def custom_validator():
""" Validator page """
......@@ -405,7 +405,7 @@ def custom_validator():
# First form display
if input_param is None:
return render_template('custom_validation_form.html', title="Schéma personnalisé",
return render_template('validation_form.html', title="Formulaire de validation",
val_info=None,
breadcrumbs=[{'url': url_for('home'), 'title': 'Accueil'}, ])
......@@ -450,60 +450,3 @@ def custom_validator():
return validate(schema_param, ValidataSource('file', f.filename, b_content))
return 'Bizarre, vous avez dit bizarre ?'
@app.route('/validators/<val_code>', methods=['GET', 'POST'])
def scdl_validator(val_code):
""" Validator page """
# if val_code == "custom":
# return custom_validator()
if not ValidatorHelper.schema_exist(val_code):
flash_error('Validateur [{}] inconnu'.format(val_code))
return redirect(url_for('home'))
if request.method == 'GET':
val_info = ValidatorHelper.schema_info(val_code)
input_param = request.args.get('input')
# First form display
if input_param is None or input_param not in ('url', 'example'):
return render_template('scdl_validation_form.html', title="val_info['title']",
val_info=val_info,
breadcrumbs=[{'url': url_for('home'), 'title': 'Accueil'}, ])
# Process URL
else:
url_param = request.args.get('url')
if url_param is None or url_param == '':
flash_error("Vous n'avez pas indiqué d'url à valider")
return redirect(url_for('scdl_validator', val_code=val_code))
try:
return validate(val_code, ValidataSource('url', url_param, url_param))
except tabulator.exceptions.FormatError as e:
flash_error('Erreur : Format de ressource non supporté')
log.info(e)
return redirect(url_for('scdl_validator', val_code=val_code))
except tabulator.exceptions.HTTPError as e:
flash_error('Erreur : impossible d\'accéder au fichier source en ligne')
log.info(e)
return redirect(url_for('scdl_validator', val_code=val_code))
else: # POST
input_param = request.form.get('input')
if input_param is None:
flash_error('Aucun fichier à valider')
return redirect(url_for('scdl_validator', val_code=val_code))
# File validation
if input_param == 'file':
f = request.files.get('file')
if f is None:
flash_warning("Vous n'avez pas indiqué de fichier à valider")
return redirect(url_for('scdl_validator', val_code=val_code))
return validate(val_code, ValidataSource('file', f.filename, bytes_data(f)))
return 'Bizarre, vous avez dit bizarre ?'
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