validation_report.html 5.87 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
<style>
Pierre Dittgen's avatar
Pierre Dittgen committed
6 7 8 9 10 11 12 13 14 15 16 17
  .popover .popover-body h2 {
    font-size: 1.2em;
    font-weight: bold;
  }
  #table-errors td h2 {
    font-size: 1em;
    font-weight: bold;
  }

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

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

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

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

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

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

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

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

Pierre Dittgen's avatar
Pierre Dittgen committed
109

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

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

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

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

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

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

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

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


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

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

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