diff --git a/lelcsc/core/context_processors.py b/lelcsc/core/context_processors.py new file mode 100644 index 0000000..4aa79bf --- /dev/null +++ b/lelcsc/core/context_processors.py @@ -0,0 +1,12 @@ +from .signals import populate_nav + + +def nav(request): + nav_items = [ + item + for _, items in populate_nav.send(sender=request) + if isinstance(items, list) + for item in items + ] + + return {"nav_items": nav_items} diff --git a/lelcsc/core/signals.py b/lelcsc/core/signals.py new file mode 100644 index 0000000..2764c3e --- /dev/null +++ b/lelcsc/core/signals.py @@ -0,0 +1,3 @@ +from django.dispatch import Signal + +populate_nav = Signal() diff --git a/lelcsc/core/templates/base.html b/lelcsc/core/templates/base.html index 4103fa8..b21abf7 100644 --- a/lelcsc/core/templates/base.html +++ b/lelcsc/core/templates/base.html @@ -13,11 +13,20 @@ {% block body %} + {% block navbar %} + {% include "partials/navbar.html" %} + {% endblock %} {% block messages %} {% bootstrap_messages %} {% endblock %} {% block content %} {% endblock %} {% endblock %} + + diff --git a/lelcsc/core/templates/core/index.html b/lelcsc/core/templates/core/index.html index 8330619..77a776a 100644 --- a/lelcsc/core/templates/core/index.html +++ b/lelcsc/core/templates/core/index.html @@ -4,10 +4,3 @@ {% load i18n %} {% block page_title %}{% translate "Overview" %}{% endblock %} - -{% block content %} -
- {% csrf_token %} - {% bootstrap_button button_type="submit" content="Log out" %} -
-{% endblock %} diff --git a/lelcsc/core/templates/partials/navbar.html b/lelcsc/core/templates/partials/navbar.html new file mode 100644 index 0000000..dd06730 --- /dev/null +++ b/lelcsc/core/templates/partials/navbar.html @@ -0,0 +1,32 @@ +{% load django_bootstrap5 %} +{% load i18n %} + diff --git a/lelcsc/settings.py b/lelcsc/settings.py index fecd796..9a24887 100644 --- a/lelcsc/settings.py +++ b/lelcsc/settings.py @@ -73,6 +73,7 @@ TEMPLATES = [ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "lelcsc.core.context_processors.nav", ], }, },