From 416d7d47f7b1bb986b6fa70107b680c614dbc523 Mon Sep 17 00:00:00 2001 From: artus Date: Sun, 21 Oct 2018 11:54:02 +0200 Subject: [PATCH] changes order in tables, fixes statistiques views navbar titles --- notes/templates/notes/details.html | 7 +++- notes/templates/notes/details_maraude.html | 15 ++++--- notes/templates/notes/details_sujet.html | 11 +++--- statistiques/templates/statistiques/base.html | 2 +- .../templates/statistiques/frequentation.html | 27 ------------- .../templates/statistiques/index.html | 3 +- .../statistiques/multiple_charts.html | 3 +- .../templates/statistiques/typologie.html | 39 ------------------- website/templatetags/tables.py | 19 +++++---- 9 files changed, 31 insertions(+), 95 deletions(-) delete mode 100644 statistiques/templates/statistiques/frequentation.html delete mode 100644 statistiques/templates/statistiques/typologie.html diff --git a/notes/templates/notes/details.html b/notes/templates/notes/details.html index c8afff4..25bee92 100644 --- a/notes/templates/notes/details.html +++ b/notes/templates/notes/details.html @@ -2,7 +2,13 @@ {% load bootstrap4 notes %} {% block page_content %} +
+ {% block top_block %}{% endblock %} +
+ +
+ {% block pagination %}{% endblock %} {% for note in notes %} {% if maraude %} @@ -12,7 +18,6 @@ {% endif %} {% endfor %}
-{% block pagination %}{% endblock %}
diff --git a/notes/templates/notes/details_maraude.html b/notes/templates/notes/details_maraude.html index 3329e56..498c6ea 100644 --- a/notes/templates/notes/details_maraude.html +++ b/notes/templates/notes/details_maraude.html @@ -29,13 +29,12 @@ {% endblock %} -{% block right_column %} -
-
Informations
-
-

Maraudeurs :  {{ maraude.binome }} & {{ maraude.referent }}

-

Nombre de rencontres  {{ maraude.rencontres.count }}

-

Nombre de personnes rencontrées  {{ maraude.observations_count }}

-
+{% block top_block %} +
+

+ avec {{ maraude.binome }} & {{ maraude.referent }} + {{ maraude.rencontres.count }} rencontres + {{ maraude.observations_count }} personnes rencontrées +

{% endblock %} diff --git a/notes/templates/notes/details_sujet.html b/notes/templates/notes/details_sujet.html index ce07279..b8d71f0 100644 --- a/notes/templates/notes/details_sujet.html +++ b/notes/templates/notes/details_sujet.html @@ -9,6 +9,12 @@ {% endblock %} +{% block top_block %} +
+ {% include "notes/details_sujet_inner.html" %} +
+{% endblock %} + {% block pagination %}
{% if notes.has_other_pages %}
    @@ -20,11 +26,6 @@ {% endblock %} {% block right_column %} -
    -
    Informations
    - {% include "notes/details_sujet_inner.html" %} -
    -
    Statistiques
    diff --git a/statistiques/templates/statistiques/base.html b/statistiques/templates/statistiques/base.html index fa83e2d..1f0ab26 100644 --- a/statistiques/templates/statistiques/base.html +++ b/statistiques/templates/statistiques/base.html @@ -12,7 +12,7 @@ {% block title %}Statistiques >{% endblock %} {% block breadcrumbs %} -
  • Statistiques
  • + {% endblock %} {% block sidebar %} diff --git a/statistiques/templates/statistiques/frequentation.html b/statistiques/templates/statistiques/frequentation.html deleted file mode 100644 index 7f06234..0000000 --- a/statistiques/templates/statistiques/frequentation.html +++ /dev/null @@ -1,27 +0,0 @@ -{% extends "statistiques/base.html" %} -{% load static %} - -{% block title %}{{ block.super }} Maraudes{% endblock %} - - -{% block sidebar %} - {{ block.super }} -
    -
    - {% include "statistiques/filter_form.html" %} -
    -
    -{% endblock %} - -{% block breadcrumbs %} - {{ block.super }} -
  • Fréquentation
  • -{% endblock %} - -{% block page_content %} - {{ rencontres_par_heure.as_html }} - {{ rencontres_par_mois.as_html }} -
    - {{ rencontres_par_sujet.as_html }} - -{% endblock %} diff --git a/statistiques/templates/statistiques/index.html b/statistiques/templates/statistiques/index.html index 3a1026e..3783e79 100644 --- a/statistiques/templates/statistiques/index.html +++ b/statistiques/templates/statistiques/index.html @@ -3,7 +3,6 @@ {% block title %}{{ block.super }} Maraudes{% endblock %} - {% block sidebar %} {{ block.super }} {% include "statistiques/filter_form.html" %} @@ -11,7 +10,7 @@ {% block breadcrumbs %} {{ block.super }} -
  • Données générales
  • + {% endblock %} {% block page_content %} diff --git a/statistiques/templates/statistiques/multiple_charts.html b/statistiques/templates/statistiques/multiple_charts.html index 2a15078..cef3137 100644 --- a/statistiques/templates/statistiques/multiple_charts.html +++ b/statistiques/templates/statistiques/multiple_charts.html @@ -4,8 +4,7 @@ {% block breadcrumbs %} {{block.super}} -
  • {{page_title}}
  • - {% if active %}
  • {{active}}
  • {% endif %} + {% endblock %} {% block sidebar %} diff --git a/statistiques/templates/statistiques/typologie.html b/statistiques/templates/statistiques/typologie.html deleted file mode 100644 index 3ddca74..0000000 --- a/statistiques/templates/statistiques/typologie.html +++ /dev/null @@ -1,39 +0,0 @@ -{% extends "statistiques/base.html" %} - -{% block title %}{{block.super}} Typologie{% endblock %} - -{% block breadcrumbs %}{{block.super}}
  • Typologie
  • {% endblock %} - -{% block sidebar %} - {{ block.super }} - {% include "statistiques/filter_form.html" %} -

    Échantillon : {{ queryset.count }} sujets

    -{% endblock %} - -{% block page_content %} - - - - {% for title, graph in graphs %} - {{ graph.as_html }} - {% endfor %} - -{% endblock %} diff --git a/website/templatetags/tables.py b/website/templatetags/tables.py index c8d74c8..79a6a1b 100644 --- a/website/templatetags/tables.py +++ b/website/templatetags/tables.py @@ -1,14 +1,15 @@ from django import template -from itertools import zip_longest +from itertools import zip_longest, islice register = template.Library() -def get_columns(iterable, cols): - cols_len = len(iterable) // cols - if len(iterable) % cols != 0: - cols_len += 1 - for i in range(cols): - yield iterable[i*cols_len:(i+1)*cols_len] +def get_rows(iterable, cols): + """ Returns a tuple of rows """ + i = iter(iterable) + row = tuple(islice(i, cols)) + while row: + yield row + row = tuple(islice(i, cols)) @register.inclusion_tag("tables/table.html") def table(object_list, cols=2, cell_template="tables/table_cell_default.html", header=None): @@ -17,8 +18,6 @@ def table(object_list, cols=2, cell_template="tables/table_cell_default.html", h 'cell_template': cell_template, 'cols_number': cols, 'header': header, - 'rows': tuple(zip_longest( *get_columns(object_list, cols), - fillvalue=None - )) + 'rows': tuple(get_rows(object_list, cols)), }