From: Jérémy Fabre Date: Wed, 27 Jul 2016 14:04:57 +0000 (+0200) Subject: Add a template tag to fetch the childrens of a given page and update the BasicPage... X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=16388993eafbd2ef79ba6ea75fd6a3947907e337;p=mezzo.git Add a template tag to fetch the childrens of a given page and update the BasicPage, Department and Team templates accordingly --- diff --git a/app/organization/core/templatetags/organization_tags.py b/app/organization/core/templatetags/organization_tags.py index 5f3c9583..01af3d58 100644 --- a/app/organization/core/templatetags/organization_tags.py +++ b/app/organization/core/templatetags/organization_tags.py @@ -16,6 +16,13 @@ register = Library() def subtract(value, arg): return value - arg +@register.as_tag +def children_pages(page_id): + childrens = Page.objects.filter(parent_id=page_id) + if childrens: + return childrens + return None + @register.as_tag def featured_edito(*args): qs = Page.objects.filter(slug="edito") diff --git a/app/templates/pages/basicpage.html b/app/templates/pages/basicpage.html index 917b90f1..084995c9 100644 --- a/app/templates/pages/basicpage.html +++ b/app/templates/pages/basicpage.html @@ -1,5 +1,5 @@ {% extends "pages/page.html" %} -{% load i18n mezzanine_tags keyword_tags featured_tags pages_tags %} +{% load i18n mezzanine_tags keyword_tags featured_tags pages_tags organization_tags %} {% block meta_title %}{{ page.meta_title }}{% endblock %} @@ -50,6 +50,21 @@ {% block main %} {{ block.super }} + {% if page.get_ascendants|length == 1 %} + {% children_pages page.id as childrens %} + {% if childrens %} +
+
+ {% for children in childrens %} + + {% endfor %} +
+
+ {% endif %} + {% endif %} + {% if page.basicpage.pageblock_set.all %}
@@ -59,7 +74,10 @@
{% for pageblock in page.basicpage.pageblock_set.all %}
-
+
+ {% if not forloop.first %} +
+ {% endif %}

{{ pageblock.title }}

{{ pageblock.content|richtext_filters|safe }}
diff --git a/app/templates/pages/department.html b/app/templates/pages/department.html index b155bb4e..8e355154 100644 --- a/app/templates/pages/department.html +++ b/app/templates/pages/department.html @@ -54,6 +54,21 @@ {% block main %} {{ block.super }} + {% if page.get_ascendants|length == 1 %} + {% children_pages page.id as childrens %} + {% if childrens %} +
+
+ {% for children in childrens %} + + {% endfor %} +
+
+ {% endif %} + {% endif %} + {% if page.department.pageblock_set.all %}
@@ -63,7 +78,10 @@
{% for pageblock in page.department.pageblock_set.all %}
-
+
+ {% if not forloop.first %} +
+ {% endif %}

{{ pageblock.title }}

{{ pageblock.content|richtext_filters|safe }}
diff --git a/app/templates/pages/team.html b/app/templates/pages/team.html index 72546fee..0298ba0b 100644 --- a/app/templates/pages/team.html +++ b/app/templates/pages/team.html @@ -50,6 +50,21 @@ {% block main %} {{ block.super }} + {% if page.get_ascendants|length == 1 %} + {% children_pages page.id as childrens %} + {% if childrens %} +
+
+ {% for children in childrens %} + + {% endfor %} +
+
+ {% endif %} + {% endif %} + {% if page.team.pageblock_set.all %}
@@ -59,7 +74,10 @@
{% for pageblock in page.team.pageblock_set.all %}
-
+
+ {% if not forloop.first %} +
+ {% endif %}

{{ pageblock.title }}

{{ pageblock.content|richtext_filters|safe }}