validation_report.html 5.31 KB
Newer Older
1
{% extends "base_template.html" %}
2

Christophe Benz's avatar
Christophe Benz committed
3 4
{% import 'schema_info_macros.html' as schema_info_macros %}
{% import 'validation_macros.html' as macros %}
5

Christophe Benz's avatar
Christophe Benz committed
6
{% block title %}{{ section_title }} – {{ schema_info.title }}{% endblock %}
7

8 9
{% block head %}
{{ super() }}
Pierre Dittgen's avatar
Pierre Dittgen committed
10
<style>
Pierre Dittgen's avatar
Pierre Dittgen committed
11 12 13 14 15 16 17 18 19 20 21 22
  .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;
23
    }
Pierre Dittgen's avatar
Pierre Dittgen committed
24
  }
Pierre Dittgen's avatar
Pierre Dittgen committed
25
</style>
26
{% endblock %}
27

28
{% block content %}
Christophe Benz's avatar
Christophe Benz committed
29 30 31

<p>Validation effectuée {{ validation_date }}</p>

32
{% if source.type == 'url' %}
Christophe Benz's avatar
Christophe Benz committed
33
<p class="hidden-print">
Christophe Benz's avatar
Christophe Benz committed
34
    <a class="btn btn-outline-secondary" href="{{ pdf_report_url }}&url={{source.url|urlencode}}" target="_blank">
Christophe Benz's avatar
Christophe Benz committed
35 36 37
        Télécharger en PDF
    </a>
</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
38
{% endif %}
Christophe Benz's avatar
Christophe Benz committed
39

40
    {# Schema info #}
Christophe Benz's avatar
Christophe Benz committed
41 42 43 44
    <div class="row my-4">
        <div class="col-lg-6 mb-4">
            <div class="card">
                <div class="card-body">
45
                    {{ schema_info_macros.html(schema_info, None, None, schema_current_version, doc_url) }}
Christophe Benz's avatar
Christophe Benz committed
46 47 48 49 50
                </div>
            </div>
        </div>
        <div class="col-lg-6">
            <div class="card">
Christophe Benz's avatar
Christophe Benz committed
51
                <div class="card-body">
Christophe Benz's avatar
Christophe Benz committed
52 53 54 55 56 57 58 59 60 61
                    <h2 class="card-title">
                        Fichier {% if report.error_count == 0 %}valide{% else %}invalide{% endif %}
                    </h2>

                    {% if display_badge %}
                    <p><img src="{{ badge_url }}" alt="{{ badge_msg }}" /></p>
                    {% endif %}

                    <p>
                        <code>
62 63
                        {% if source.type == 'file' %}
                            {{ source.filename }}
Christophe Benz's avatar
Christophe Benz committed
64 65
                        {% elif source.type == 'url' %}
                            <a href="{{source.url}}" target="_blank">{{source.filename}}</a>
66
                        {% endif %}
Christophe Benz's avatar
Christophe Benz committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
                        </code>
                        ({{ report.table.col_count }} colonnes × {{ report.table.row_count }} lignes)
                    </p>

                    {% if report.error_count == 0 %}
                    <p>Aucune erreur détectée</p>
                    {% else %}
                    {{ macros.error_statistics(report) }}
                    <p>
                        {% set error_count = report.table['error-stats']['count'] %}
                        Total :
                        {% if error_count == 1 %}
                        1 erreur détectée
                        {% else %}
                        {{ error_count }} erreurs détectées
82
                        {% endif %}
Christophe Benz's avatar
Christophe Benz committed
83 84
                    </p>
                    {% endif %}
85
                </div>
Pierre Dittgen's avatar
Pierre Dittgen committed
86 87
            </div>
        </div>
88 89
    </div>

90
    {% if report.error_count == 0 %}
91

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

94
    {% else %}
95

Pierre Dittgen's avatar
Pierre Dittgen committed
96
    {% if report.table.errors.structure %}
Christophe Benz's avatar
Christophe Benz committed
97
        <h3 class="my-4">Erreurs de structure</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
        {# 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
115
        <table class="table table-bordered table-sm table-striped table-hover">
Pierre Dittgen's avatar
Pierre Dittgen committed
116 117 118
            <thead class="thead-light">
                <tr>
                    <th scope="col">Colonnes du fichier</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
119
                    <th scope="col">Colonnes attendues</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
120 121 122
                </tr>
            </thead>
            <tbody>
123
                {% for elt in report.table.column_comparison_info.table %}
Pierre Dittgen's avatar
Pierre Dittgen committed
124
                    <tr{% if elt[2] == 'ko' %} class="table-danger"{% endif %}>
Pierre Dittgen's avatar
Pierre Dittgen committed
125 126
                        <td>{{ elt[0] }}</td>
                        <td>{{ elt[1] }}</td>
Pierre Dittgen's avatar
Pierre Dittgen committed
127 128 129 130
                    </tr>
                {% endfor %}
            </tbody>
        </table>
131
        {% if report.table.column_comparison_info.has_missing %}
Pierre Dittgen's avatar
Pierre Dittgen committed
132
        <p>Attention : toutes les colonnes attendues doivent être présentes dans le fichier à valider.<p>
133 134 135 136
        {% 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
137

138
        {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
139
    {% endif %}
140

Pierre Dittgen's avatar
Pierre Dittgen committed
141 142
    {# We do display body errors! #}
    {% if report.table.do_display_body_errors %}
Christophe Benz's avatar
Christophe Benz committed
143
    <h3 class="my-4">Erreurs de contenu</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
144 145

    {# No errors - display preview #}
146
    {% if not report.table.errors.body %}
Christophe Benz's avatar
Christophe Benz committed
147
    <p>
148 149
        Aucune erreur de contenu
    </p>
Pierre Dittgen's avatar
Pierre Dittgen committed
150
    {{ macros.preview(source_data) }}
Christophe Benz's avatar
Christophe Benz committed
151

Pierre Dittgen's avatar
Pierre Dittgen committed
152
    {% else %}
153

Pierre Dittgen's avatar
Pierre Dittgen committed
154
    {# display errors #}
Pierre Dittgen's avatar
Pierre Dittgen committed
155
    {{ macros.body_errors(report, source_data, print_mode) }}
Christophe Benz's avatar
Christophe Benz committed
156

157
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
158

Pierre Dittgen's avatar
Pierre Dittgen committed
159 160
    {# do not display errors #}
    {% else %}
Christophe Benz's avatar
Christophe Benz committed
161
    <p>
Pierre Dittgen's avatar
Pierre Dittgen committed
162
        Veuillez corriger ces erreurs pour visualiser les éventuelles erreurs de contenu.
163 164
    </p>
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
165
    {% endif %}
166 167 168


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

Christophe Benz's avatar
Christophe Benz committed
170
{% block page_scripts %}
Christophe Benz's avatar
Christophe Benz committed
171 172
<script>
$(function() {
Pierre Dittgen's avatar
Pierre Dittgen committed
173 174 175 176 177 178
    // Errors tooltip activate
    $('[data-toggle="popover"]').popover({
      html: true,
      placement: "auto",
      trigger: "hover"
    });
Christophe Benz's avatar
Christophe Benz committed
179
});
Pierre Dittgen's avatar
Pierre Dittgen committed
180
</script>
Christophe Benz's avatar
Christophe Benz committed
181
{% endblock %}