diff --git a/re2o/context_processors.py b/re2o/context_processors.py index 6beac564..739f4ab8 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -29,7 +29,8 @@ from django.contrib import messages from django.http import HttpRequest from preferences.models import GeneralOption, OptionalMachine from django.utils.translation import get_language - +from importlib import import_module +from re2o.settings_local import OPTIONNAL_APPS def context_user(request): """Fonction de context lorsqu'un user est logué (ou non), @@ -57,6 +58,13 @@ def context_user(request): 'ipv6_enabled': OptionalMachine.get_cached_value('ipv6'), } +def context_optionnal_apps(request): + """Fonction de context pour générer la navbar en fonction des + apps optionnels""" + optionnal_apps = [import_module(app) for app in OPTIONNAL_APPS] + optionnal_templates_navbar_list = [app.views.navbar(request) for app in optionnal_apps] + return {'optionnal_templates_navbar_list':optionnal_templates_navbar_list} + def date_now(request): """Add the current date in the context for quick informations and diff --git a/re2o/settings.py b/re2o/settings.py index 14907570..ee219cfa 100644 --- a/re2o/settings.py +++ b/re2o/settings.py @@ -132,6 +132,7 @@ TEMPLATES = [ 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.request', 're2o.context_processors.context_user', + 're2o.context_processors.context_optionnal_apps', 're2o.context_processors.date_now', ], }, diff --git a/templates/base.html b/templates/base.html index 6d39f8c8..67799c28 100644 --- a/templates/base.html +++ b/templates/base.html @@ -101,9 +101,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,