Prepare for dynamic generation of navigation menus

This commit is contained in:
Kumi 2021-03-03 11:36:25 +01:00
parent 30bc1deb73
commit fb8cb5f298
4 changed files with 103 additions and 85 deletions

View file

@ -1,3 +1,5 @@
{% load navigation %}
<!-- Sidebar -->
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">
@ -12,84 +14,7 @@
<!-- Divider -->
<hr class="sidebar-divider my-0">
<!-- Nav Item - Dashboard -->
<li class="nav-item {% if title == "Dashboard" %}active{% endif %}">
<a class="nav-link" href="{% url "frontend:dashboard" %}">
<i class="fas fa-fw fa-tachometer-alt"></i>
<span>Dashboard</span></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider">
<!-- Heading -->
<div class="sidebar-heading">
Mood
</div>
<!-- Nav Item - Status List -->
<li class="nav-item {% if title == "Status List" %}active{% endif %}">
<a class="nav-link" href="{% url "mood:status_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Status List</span></a>
</li>
<!-- Nav Item - Activity List -->
<li class="nav-item {% if title == "Activities" %}active{% endif %}">
<a class="nav-link" href="{% url "mood:activity_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Activities</span></a>
</li>
<!-- Nav Item - Mood List -->
<li class="nav-item {% if title == "Moods" %}active{% endif %}">
<a class="nav-link" href="{% url "mood:mood_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Moods</span></a>
</li>
<!-- Nav Item - Notification List -->
<li class="nav-item {% if title == "Notifications" %}active{% endif %}">
<a class="nav-link" href="{% url "mood:notification_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Notifications</span></a>
</li>
<!-- Nav Item - Notification List -->
<li class="nav-item {% if title == "Statistics" %}active{% endif %}">
<a class="nav-link" href="{% url "mood:statistics" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Statistics</span></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider">
<!-- Heading -->
<div class="sidebar-heading">
Dreams
</div>
<!-- Nav Item - Dream List -->
<li class="nav-item {% if title == "Dream List" %}active{% endif %}">
<a class="nav-link" href="{% url "dreams:dream_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Dream List</span></a>
</li>
<!-- Nav Item - Theme List -->
<li class="nav-item {% if title == "Themes" %}active{% endif %}">
<a class="nav-link" href="{% url "dreams:theme_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Themes</span></a>
</li>
<!-- Nav Item - Notification List -->
<li class="nav-item {% if title == "Notifications" %}active{% endif %}">
<a class="nav-link" href="{% url "dreams:notification_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Notifications</span></a>
</li>
{% sidebar_nav %}
<!-- Divider -->
<hr class="sidebar-divider d-none d-md-block">

View file

View file

@ -0,0 +1,85 @@
from django import template
register = template.Library()
@register.simple_tag
def sidebar_nav():
return """
<li class="nav-item {% if title == "Dashboard" %}active{% endif %}">
<a class="nav-link" href="{% url "frontend:dashboard" %}">
<i class="fas fa-fw fa-tachometer-alt"></i>
<span>Dashboard</span></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider">
<!-- Heading -->
<div class="sidebar-heading">
Mood
</div>
<!-- Nav Item - Status List -->
<li class="nav-item {% if title == "Status List" %}active{% endif %}">
<a class="nav-link" href="{% url "mood:status_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Status List</span></a>
</li>
<!-- Nav Item - Activity List -->
<li class="nav-item {% if title == "Activities" %}active{% endif %}">
<a class="nav-link" href="{% url "mood:activity_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Activities</span></a>
</li>
<!-- Nav Item - Mood List -->
<li class="nav-item {% if title == "Moods" %}active{% endif %}">
<a class="nav-link" href="{% url "mood:mood_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Moods</span></a>
</li>
<!-- Nav Item - Notification List -->
<li class="nav-item {% if title == "Notifications" %}active{% endif %}">
<a class="nav-link" href="{% url "mood:notification_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Notifications</span></a>
</li>
<!-- Nav Item - Notification List -->
<li class="nav-item {% if title == "Statistics" %}active{% endif %}">
<a class="nav-link" href="{% url "mood:statistics" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Statistics</span></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider">
<!-- Heading -->
<div class="sidebar-heading">
Dreams
</div>
<!-- Nav Item - Dream List -->
<li class="nav-item {% if title == "Dream List" %}active{% endif %}">
<a class="nav-link" href="{% url "dreams:dream_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Dream List</span></a>
</li>
<!-- Nav Item - Theme List -->
<li class="nav-item {% if title == "Themes" %}active{% endif %}">
<a class="nav-link" href="{% url "dreams:theme_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Themes</span></a>
</li>
<!-- Nav Item - Notification List -->
<li class="nav-item {% if title == "Notifications" %}active{% endif %}">
<a class="nav-link" href="{% url "dreams:notification_list" %}">
<i class="fas fa-fw fa-smile"></i>
<span>Notifications</span></a>
</li>
"""

View file

@ -1,3 +1,8 @@
# You shouldn't have to change anything in here, ever.
# Use localsettings.py in the project's root directory instead.
# If you make any changes in here, you may have trouble updating your Kumify installation.
from pathlib import Path
from localsettings import *
@ -7,6 +12,15 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# Application definition
ENABLED_MODULES = [
'cbt',
'dreams',
'health',
'friends',
'habits',
'mood',
]
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
@ -19,15 +33,9 @@ INSTALLED_APPS = [
'dbsettings',
'common',
'frontend',
'mood',
'msgio',
'cronhandler',
'cbt',
'dreams',
'health',
'friends',
'habits',
]
] + ENABLED_MODULES
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',