From 0c777a525be9afaa3f56eaeeaeccc929edd3ba8a Mon Sep 17 00:00:00 2001 From: Pierre Dittgen Date: Mon, 3 Jun 2019 16:13:07 +0200 Subject: [PATCH] Remove unused code --- .../templates/scdl_validation_form.html | 102 ------------------ ...idation_form.html => validation_form.html} | 2 +- validata_ui/views.py | 61 +---------- 3 files changed, 3 insertions(+), 162 deletions(-) delete mode 100644 validata_ui/templates/scdl_validation_form.html rename validata_ui/templates/{custom_validation_form.html => validation_form.html} (98%) diff --git a/validata_ui/templates/scdl_validation_form.html b/validata_ui/templates/scdl_validation_form.html deleted file mode 100644 index f6f457c..0000000 --- a/validata_ui/templates/scdl_validation_form.html +++ /dev/null @@ -1,102 +0,0 @@ -{% extends "base_template.html" %} -{% block title %}{{ title }}{% endblock %} -{% block head %} -{{ super() }} -{% endblock %} -{% block content %} -

Schéma « {{ title }} »

- -{% set cols_my_classes = 'my-md-0 my-4' %} -
-
-
-
-
- Schéma {{ val_info.code }} - {% if val_info.version %} - {{ val_info.version }} - {% else %} - dev - {% endif %} -
-
{{ val_info.description }}
- {% if val_info.author or val_info.contributor %} -

- {% if val_info.author %} - Auteur : {{ val_info.author }} - {% endif %} - {% if val_info.contributor %} -
Contributeur(s) : {{ val_info.contributor }} - {% endif %} -

- {% endif %} - Documentation -
-
-
- -
-

Outil de validation

- -

Validez ici le fichier de votre choix

- - {% set padding_class = 'p-3' %} -
-
-
- -
- - -
- -
-
-
-
- -
- - - -
- -
-
-
-
- -
- - -
- -
-
-
-
-
- -{% endblock %} -{% block footer %} -{% endblock %} \ No newline at end of file diff --git a/validata_ui/templates/custom_validation_form.html b/validata_ui/templates/validation_form.html similarity index 98% rename from validata_ui/templates/custom_validation_form.html rename to validata_ui/templates/validation_form.html index a407c6f..96e26c7 100644 --- a/validata_ui/templates/custom_validation_form.html +++ b/validata_ui/templates/validation_form.html @@ -2,7 +2,7 @@ block head %} {{ super() }} {% endblock %} {% block content %} -

Validateur personnalisé

+

Formulaire de validation

{# {% set cols_my_classes = 'my-md-0 my-4' %}
diff --git a/validata_ui/views.py b/validata_ui/views.py index d153c0e..24c99b4 100644 --- a/validata_ui/views.py +++ b/validata_ui/views.py @@ -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/', 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 ?' -- GitLab