From 80384f9f2a1119fa3d832c37754988e166b0ead8 Mon Sep 17 00:00:00 2001
From: Tom Teichler <tom.teichler@teckids.org>
Date: Sun, 18 Aug 2019 11:41:29 +0200
Subject: [PATCH] Migrate core menus to django-menu-generator.

---
 biscuit/core/menus.py                         |  1 -
 .../templates/bootstrap4-navbar-submenu.html  | 16 +++----
 biscuit/core/templates/bootstrap4-navbar.html | 44 +++++++++----------
 biscuit/core/templates/core/base.html         | 18 +-------
 4 files changed, 30 insertions(+), 49 deletions(-)

diff --git a/biscuit/core/menus.py b/biscuit/core/menus.py
index d10b18d8a..082e514c2 100644
--- a/biscuit/core/menus.py
+++ b/biscuit/core/menus.py
@@ -1,4 +1,3 @@
-<<<<<<< HEAD
 MENUS = {
     'NAV_MENU_CORE': [
         {
diff --git a/biscuit/core/templates/bootstrap4-navbar-submenu.html b/biscuit/core/templates/bootstrap4-navbar-submenu.html
index 417a45e82..d6f441ed2 100644
--- a/biscuit/core/templates/bootstrap4-navbar-submenu.html
+++ b/biscuit/core/templates/bootstrap4-navbar-submenu.html
@@ -1,14 +1,12 @@
 {# -*- engine:django -*- #}
 <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
     {% for item in items %}
-        {% if item.visible %}
-            <a class="dropdown-item {% if item.selected %} active{% endif %}{% if item.children %} dropdown-submenu{% endif %}" href="{{ item.url }}">{{ item.title }}
-                {% if item.children %}
-                    {% with items=item.children template_name='bootstrap-navbar-submenu.html' %}
-                       {% include template_name %}
-                    {% endwith %}
-                {% endif %}
-            </a>
-        {% endif %}
+        <a class="dropdown-item {% if item.selected %} active{% endif %}{% if item.submenu %} dropdown-submenu{% endif %}" href="{{ item.url }}">{{ item.name }}
+            {% if item.submenu %}
+                {% with items=item.submenu template_name='bootstrap4-navbar-submenu.html' %}
+                   {% include template_name %}
+                {% endwith %}
+            {% endif %}
+        </a>
     {% endfor %}
 </div>
diff --git a/biscuit/core/templates/bootstrap4-navbar.html b/biscuit/core/templates/bootstrap4-navbar.html
index 9d0b18ea6..fe49b9b81 100644
--- a/biscuit/core/templates/bootstrap4-navbar.html
+++ b/biscuit/core/templates/bootstrap4-navbar.html
@@ -1,23 +1,23 @@
 {# -*- engine:django -*- #}
-{% for item in menu %}
-    {% if item.visible %}
-        {% if item.separator %}
-            <li class="divider-vertical"></li>
-        {% endif %}
-
-        <li class="nav-item {% if item.selected %} active{% endif %}{% if item.children %} dropdown{% endif %}" id="top-menu-{{ item.slug }}">
-            <a href="{{ item.url }}" {% if not item.children %}class=nav-link {% endif%} {% if item.children %} class="nav-link dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"{% endif %}>
-                {% if item.icon %}
-                    <i class="icon-{{ item.icon }} icon-white"></i>&nbsp;
-                {% endif %}
-                <span>{{ item.title }}</span>
-                {% if item.children %}
-                    &nbsp;<b class="caret"></b>
-                {% endif %}
-            </a>
-            {% if item.children %}
-                {% include 'bootstrap4-navbar-submenu.html' with items=item.children %}
-            {% endif %}
-        </li>
-    {% endif %}
-{% endfor %}
+{% load menu_generator %}
+    {% get_menu "NAV_MENU_CORE" as core_menu %}
+    <ul class="nav navbar-nav ml-auto">
+     {% for item in core_menu %}
+      {% if not item.submenu %}
+       <li class="{% if item.selected %} active {% endif %} nav-item">
+        <a href="{{ item.url }}" class="nav-link"> <i class="{{ item.icon_class }}"></i> {{ item.name }}</a>
+       </li>
+      {% endif %}
+      {% if item.submenu %}
+       <a class="nav-link dropdown-toggle" data-toggle="dropdown" id="navbarDropdown" aria-expanded="false" role="button" aria-haspopup="true" href="#">
+        {{ item.name }}
+       </a>
+       <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
+        {% for menu in item.submenu %}
+        <a class="dropdown-item" href="{{ menu.url }}">
+         {{ menu.name }}
+        </a>
+        {% endfor %}
+       </div>
+      {% endif %}
+     {% endfor %}
diff --git a/biscuit/core/templates/core/base.html b/biscuit/core/templates/core/base.html
index fd2d2ced3..09124833c 100644
--- a/biscuit/core/templates/core/base.html
+++ b/biscuit/core/templates/core/base.html
@@ -25,28 +25,12 @@
     <a class="navbar-brand" href="{% url "index" %}">
      <span class="glyphicon glyphicon-briefcase"></span> BiscuIT School Information System
     </a>
-   </div>
 
    <div class="collapse navbar-collapse" id="navbar-main">
-    {% get_menu "NAV_MENU_CORE" as core_menu %}
     <ul class="nav navbar-nav ml-auto">
-     {% for item in core_menu %}
-      <li class="{% if item.selected %} active {% endif %} nav-item">
-       <a href="{{ item.url }}" class="nav-link"> <i class="{{ item.icon_class }}"></i> {{ item.name }}</a>
-      </li>
-      {% if item.submenu %}
-      <div class="dropdown-menu dropdown-menu-righy" aria-labelledby="navbarDropdown">>
-       {% for menu in item.submenu %}
-       <a class="dropdown-item" href="{{ menu.url }}">
-        {{ menu.name }}
-       </a>
-       {% endfor %}
-      </div>
-      {% endif %}
-     {% endfor %}
+     {% with menu=NAV_MENU_CORE %}{% include "bootstrap4-navbar.html" %}{% endwith %}
     </ul>
    </div>
-  </div>
  </nav>
 
  <div class="container">
-- 
GitLab