]> git.parisson.com Git - mezzo.git/commitdiff
Add a template tag to fetch the childrens of a given page and update the BasicPage...
authorJérémy Fabre <blackmagik88@gmail.com>
Wed, 27 Jul 2016 14:04:57 +0000 (16:04 +0200)
committerJérémy Fabre <blackmagik88@gmail.com>
Wed, 27 Jul 2016 14:04:57 +0000 (16:04 +0200)
app/organization/core/templatetags/organization_tags.py
app/templates/pages/basicpage.html
app/templates/pages/department.html
app/templates/pages/team.html

index 5f3c95830887b466d208868fc7a73a1c51e731c9..01af3d58fcc18309f8fc198b1bfbe642d0437875 100644 (file)
@@ -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")
index 917b90f12f5c0cb5db8a5062102ddd3748ff7798..084995c9f4efe764909088ca968d7eb8c470c0ba 100644 (file)
@@ -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 %}
 
 {% block main %}
     {{ block.super }}
 
+    {% if page.get_ascendants|length == 1 %}
+        {% children_pages page.id as childrens %}
+        {% if childrens %}
+            <div class="container">
+                <div class="row">
+                    {% for children in childrens %}
+                        <div class="col-sm-9 col-sm-push-3 col-lg-8 col-lg-push-2">
+                            <a href="{{ children.get_absolute_url }}" title="{{ children.title }}">{{ children.title }}</a>
+                        </div>
+                    {% endfor %}
+                </div>
+            </div>
+        {% endif %}
+    {% endif %}
+
     {% if page.basicpage.pageblock_set.all %}
         <div class="white-bg">
             <div class="container">
                             <hr class="mt0" />
                             {% for pageblock in page.basicpage.pageblock_set.all %}
                                 <div class="row" data-summary-content>
-                                    <div class="col-sm-9 col-sm-push-3 col-lg-8 col-lg-push-2 white-bg">
+                                    <div class="col-sm-9 col-sm-push-3 col-lg-8 col-lg-push-2 white-bg" data-summary-content>
+                                        {% if not forloop.first %}
+                                            <hr />
+                                        {% endif %}
                                         <h2 class="dotted">{{ pageblock.title }}</h2>
                                         {{ pageblock.content|richtext_filters|safe }}
                                     </div>
index b155bb4e204f5f235291d2d44376f2133299a396..8e355154b8cd9c1666afd10851a41e040678264e 100644 (file)
 {% block main %}
     {{ block.super }}
 
+    {% if page.get_ascendants|length == 1 %}
+        {% children_pages page.id as childrens %}
+        {% if childrens %}
+            <div class="container">
+                <div class="row">
+                    {% for children in childrens %}
+                        <div class="col-sm-9 col-sm-push-3 col-lg-8 col-lg-push-2">
+                            <a href="{{ children.get_absolute_url }}" title="{{ children.title }}">{{ children.title }}</a>
+                        </div>
+                    {% endfor %}
+                </div>
+            </div>
+        {% endif %}
+    {% endif %}
+
     {% if page.department.pageblock_set.all %}
         <div class="white-bg">
             <div class="container">
                             <hr class="mt0" />
                             {% for pageblock in page.department.pageblock_set.all %}
                                 <div class="row">
-                                    <div class="col-sm-9 col-sm-push-3 col-lg-8 col-lg-push-2 white-bg">
+                                    <div class="col-sm-9 col-sm-push-3 col-lg-8 col-lg-push-2 white-bg" data-summary-content>
+                                        {% if not forloop.first %}
+                                            <hr />
+                                        {% endif %}
                                         <h2 class="dotted">{{ pageblock.title }}</h2>
                                         {{ pageblock.content|richtext_filters|safe }}
                                     </div>
index 72546feeb61649406c16110fcea55f2341d23818..0298ba0be3228b29e2f6a5212f10f2dc6c1d7bd1 100644 (file)
 {% block main %}
     {{ block.super }}
 
+    {% if page.get_ascendants|length == 1 %}
+        {% children_pages page.id as childrens %}
+        {% if childrens %}
+            <div class="container">
+                <div class="row">
+                    {% for children in childrens %}
+                        <div class="col-sm-9 col-sm-push-3 col-lg-8 col-lg-push-2">
+                            <a href="{{ children.get_absolute_url }}" title="{{ children.title }}">{{ children.title }}</a>
+                        </div>
+                    {% endfor %}
+                </div>
+            </div>
+        {% endif %}
+    {% endif %}
+
     {% if page.team.pageblock_set.all %}
         <div class="white-bg">
             <div class="container">
                             <hr class="mt0" />
                             {% for pageblock in page.team.pageblock_set.all %}
                                 <div class="row">
-                                    <div class="col-sm-9 col-sm-push-3 col-lg-8 col-lg-push-2 white-bg">
+                                    <div class="col-sm-9 col-sm-push-3 col-lg-8 col-lg-push-2 white-bg" data-summary-content>
+                                        {% if not forloop.first %}
+                                            <hr />
+                                        {% endif %}
                                         <h2 class="dotted">{{ pageblock.title }}</h2>
                                         {{ pageblock.content|richtext_filters|safe }}
                                     </div>