validation_report.html 5.89 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
    #table-errors td h2 {
        font-size: 1em;
        font-weight: bold;
    }
Pierre Dittgen's avatar
Pierre Dittgen committed
14

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

Pierre Dittgen's avatar
Pierre Dittgen committed
85
    {% import 'validation_macros.html' as macros %}
Pierre Dittgen's avatar
Pierre Dittgen committed
86

87 88 89
    {% 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
90

Pierre Dittgen's avatar
Pierre Dittgen committed
91
    {{ macros.preview(source_data) }}
Pierre Dittgen's avatar
Pierre Dittgen committed
92

93
    {% else %}
Pierre Dittgen's avatar
Pierre Dittgen committed
94

95
    <h2>La table est invalide</h2>
Pierre Dittgen's avatar
Pierre Dittgen committed
96

Pierre Dittgen's avatar
Pierre Dittgen committed
97 98 99 100 101 102 103 104
    <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
105

Pierre Dittgen's avatar
Pierre Dittgen committed
106
    {{ macros.error_statistics(report) }}
Pierre Dittgen's avatar
Pierre Dittgen committed
107

Pierre Dittgen's avatar
Pierre Dittgen committed
108

Pierre Dittgen's avatar
Pierre Dittgen committed
109
    {% if report.table.errors.structure %}
Pierre Dittgen's avatar
Pierre Dittgen committed
110
        <h3>Erreurs de structure</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
        {# 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
128
        <table class="table table-bordered table-sm table-striped table-hover">
Pierre Dittgen's avatar
Pierre Dittgen committed
129 130 131
            <thead class="thead-light">
                <tr>
                    <th scope="col">Colonnes du fichier</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
132
                    <th scope="col">Colonnes attendues</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
133 134 135
                </tr>
            </thead>
            <tbody>
136
                {% for elt in report.table.column_comparison_info.table %}
Pierre Dittgen's avatar
Pierre Dittgen committed
137
                    <tr{% if elt[2] == 'ko' %} class="table-danger"{% endif %}>
Pierre Dittgen's avatar
Pierre Dittgen committed
138 139
                        <td>{{ elt[0] }}</td>
                        <td>{{ elt[1] }}</td>
Pierre Dittgen's avatar
Pierre Dittgen committed
140 141 142 143
                    </tr>
                {% endfor %}
            </tbody>
        </table>
144
        {% if report.table.column_comparison_info.has_missing %}
Pierre Dittgen's avatar
Pierre Dittgen committed
145
        <p>Attention : toutes les colonnes attendues doivent être présentes dans le fichier à valider.<p>
146 147 148 149
        {% 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
150

151
        {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
152
    {% endif %}
153

Pierre Dittgen's avatar
Pierre Dittgen committed
154 155
    {# We do display body errors! #}
    {% if report.table.do_display_body_errors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
156
    <h3>Erreurs de contenu</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
157 158

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

Pierre Dittgen's avatar
Pierre Dittgen committed
165
    {% else %}
166

Pierre Dittgen's avatar
Pierre Dittgen committed
167
    {# display errors #}
Pierre Dittgen's avatar
Pierre Dittgen committed
168
    {{ macros.body_errors(report, source_data, print_mode) }}
Christophe Benz's avatar
Christophe Benz committed
169

170
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
171

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


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

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

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