validation_report.html 5.77 KB
Newer Older
1
{% extends "base_template.html" %}
2 3 4
{% block title %}{{ title }}{% endblock %}
{% block head %}
{{ super() }}
Pierre Dittgen's avatar
Pierre Dittgen committed
5 6 7 8 9
<style>
    .popover .popover-body h2 {
        font-size: 1.2em;
        font-weight: bold;
    }
Pierre Dittgen's avatar
Pierre Dittgen committed
10

11 12 13 14 15
    @media print {
        .hidden-print {
            display: none;
        }
    }
Pierre Dittgen's avatar
Pierre Dittgen committed
16
</style>
17 18
{% endblock %}
{% block content %}
19
{% if print_mode %}
Pierre Dittgen's avatar
Pierre Dittgen committed
20
<div class="row">
21
    <div class="col-md-5">
Pierre Dittgen's avatar
Pierre Dittgen committed
22
{% endif %}
23
        <h1>{{ title }}</h1>
Christophe Benz's avatar
Christophe Benz committed
24
        <p>Validation effectuée {{ validation_date }}</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
25
{% if print_mode %}
26 27 28 29 30 31 32
    </div>
    <div class="col-md-7">
        <img src="{{ url_for('static', filename='img/logo-horizontal.png') }}" height="80" alt="Validata" />
    </div>
</div>
{% endif %}
{% if source.type == 'url' %}
Christophe Benz's avatar
Christophe Benz committed
33 34 35 36 37
<p class="hidden-print">
    <a href="{{ url_for('pdf_report', val_code=val_info.code) }}?url={{source.name|urlencode}}">
        Télécharger en PDF
    </a>
</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
38
{% endif %}
39 40 41 42 43 44 45 46 47 48 49
    {# Schema info #}
    <div class="row">
        <div class="col-md-{% if print_mode %}12{% else %}5{% endif %} my-4">
            <div class="card bg-faded">
                <div class="card-body">
                    <h5 class="card-title">
                        Schéma {{ val_info.code }}
                        <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 %}
Christophe Benz's avatar
Christophe Benz committed
50
                    <p>
51 52 53 54 55 56 57
                        {% if val_info.author %}
                        Auteur : {{ val_info.author }}
                        {% endif %}
                        {% if val_info.contributor %}
                        <br />Contributeur(s) : {{ val_info.contributor }}
                        {% endif %}
                    </p>
Pierre Dittgen's avatar
Pierre Dittgen committed
58
                    {% endif %}
59
                    <p>
60
                        <a href="{{ val_info.doc_url }}" target="_blank" class="card-link">Documentation</a>
61 62
                    </p>
                    <hr />
Christophe Benz's avatar
Christophe Benz committed
63 64
                    <div>
                        Fichier traité :
65
                        {% if source_type == 'file' %}
Christophe Benz's avatar
Christophe Benz committed
66
                            {{ source.name }}
67 68
                        {% endif %}
                        {% if source_type == 'url' %}
Christophe Benz's avatar
Christophe Benz committed
69
                            <a href="{{source.name}}" target="_blank">
70
                                {{source.name}}
Christophe Benz's avatar
Christophe Benz committed
71
                            </a>
72 73
                        {% endif %}
                        <br />
Christophe Benz's avatar
Christophe Benz committed
74 75
                        Dimensions : {{ report.table.col_count }} colonnes et {{ report.table.row_count }} lignes
                    </div>
76
                </div>
Pierre Dittgen's avatar
Pierre Dittgen committed
77 78
            </div>
        </div>
79 80
    </div>

Pierre Dittgen's avatar
Pierre Dittgen committed
81
    {% import 'validation_macros.html' as macros %}
Pierre Dittgen's avatar
Pierre Dittgen committed
82

83 84 85
    {% if report.error_count == 0 %}
    <h2>La table est valide</h2>
    <p>Aucune erreur détectée</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
86

Pierre Dittgen's avatar
Pierre Dittgen committed
87
    {{ macros.preview(source_data) }}
Pierre Dittgen's avatar
Pierre Dittgen committed
88

89
    {% else %}
Pierre Dittgen's avatar
Pierre Dittgen committed
90

91
    <h2>La table est invalide</h2>
Pierre Dittgen's avatar
Pierre Dittgen committed
92

Pierre Dittgen's avatar
Pierre Dittgen committed
93 94 95 96 97 98 99 100
    <p>
        {% set error_count = report.table['error-stats']['count'] %}
        {% if error_count == 1 %}
        1 erreur détectée.
        {% else %}
        {{ error_count }} erreurs détectées.
        {% endif %}
    </p>
Pierre Dittgen's avatar
Pierre Dittgen committed
101

Pierre Dittgen's avatar
Pierre Dittgen committed
102
    {{ macros.error_statistics(report) }}
Pierre Dittgen's avatar
Pierre Dittgen committed
103

Pierre Dittgen's avatar
Pierre Dittgen committed
104

Pierre Dittgen's avatar
Pierre Dittgen committed
105
    {% if report.table.errors.structure %}
Pierre Dittgen's avatar
Pierre Dittgen committed
106
        <h3>Erreurs de structure</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
        {# Non-column errors #}
        {% for err in report.table.errors.structure %}
            {% if not err.in_column_comp %}
                {{ err.content | safe }}
            {% endif %}
        {% endfor %}

        {# Column errors #}
        {% for err in report.table.errors.structure %}
            {% if err.in_column_comp %}
                {{ err.content | safe }}
            {% endif %}
        {% endfor %}


        {# Afficher un tableau de comparaison des colonnes #}
        {% if report.table.column_comparison_needed %}
Christophe Benz's avatar
Christophe Benz committed
124
        <table class="table table-bordered table-sm table-striped table-hover">
Pierre Dittgen's avatar
Pierre Dittgen committed
125 126 127
            <thead class="thead-light">
                <tr>
                    <th scope="col">Colonnes du fichier</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
128
                    <th scope="col">Colonnes attendues</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
129 130 131
                </tr>
            </thead>
            <tbody>
132
                {% for elt in report.table.column_comparison_info.table %}
Pierre Dittgen's avatar
Pierre Dittgen committed
133
                    <tr{% if elt[2] == 'ko' %} class="table-danger"{% endif %}>
Pierre Dittgen's avatar
Pierre Dittgen committed
134 135
                        <td>{{ elt[0] }}</td>
                        <td>{{ elt[1] }}</td>
Pierre Dittgen's avatar
Pierre Dittgen committed
136 137 138 139
                    </tr>
                {% endfor %}
            </tbody>
        </table>
140
        {% if report.table.column_comparison_info.has_missing %}
Pierre Dittgen's avatar
Pierre Dittgen committed
141
        <p>Attention : toutes les colonnes attendues doivent être présentes dans le fichier à valider.<p>
142 143 144 145
        {% endif %}
        {% if report.table.column_comparison_info.has_case_errors %}
        <p>Attention : la casse (minuscules/majuscules) doit être respectée dans les noms de colonne.<p>
        {% endif %}
Christophe Benz's avatar
Christophe Benz committed
146

147
        {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
148
    {% endif %}
149

Pierre Dittgen's avatar
Pierre Dittgen committed
150 151
    {# We do display body errors! #}
    {% if report.table.do_display_body_errors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
152
    <h3>Erreurs de contenu</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
153 154

    {# No errors - display preview #}
155
    {% if not report.table.errors.body %}
Christophe Benz's avatar
Christophe Benz committed
156
    <p>
157 158
        Aucune erreur de contenu
    </p>
Pierre Dittgen's avatar
Pierre Dittgen committed
159
    {{ macros.preview(source_data) }}
Christophe Benz's avatar
Christophe Benz committed
160

Pierre Dittgen's avatar
Pierre Dittgen committed
161
    {% else %}
162

Pierre Dittgen's avatar
Pierre Dittgen committed
163
    {# display errors #}
Pierre Dittgen's avatar
Pierre Dittgen committed
164
    {{ macros.body_errors(report, source_data) }}
Christophe Benz's avatar
Christophe Benz committed
165

166
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
167

Pierre Dittgen's avatar
Pierre Dittgen committed
168 169
    {# do not display errors #}
    {% else %}
Christophe Benz's avatar
Christophe Benz committed
170
    <p>
Pierre Dittgen's avatar
Pierre Dittgen committed
171
        Veuillez corriger ces erreurs pour visualiser les éventuelles erreurs de contenu.
172 173
    </p>
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
174
    {% endif %}
175 176 177


    {% endblock %}
Pierre Dittgen's avatar
Pierre Dittgen committed
178

179 180 181 182 183 184 185 186 187
    {% block footer %}
    <script>
        $(function () {
            // Errors tooltip activate
            $('[data-toggle="popover"]').popover({
                html: true,
                placement: 'auto',
                trigger: 'hover'
            });
188
        })
189
    </script>
190

Pierre Dittgen's avatar
Pierre Dittgen committed
191
    {% endblock %}