8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

Inclusion des apps optionnels dans le navbar (je sais pas trop pourquoi ça marche ça risque de casser)

This commit is contained in:
Grizzly 2019-08-10 17:25:21 +00:00 committed by Gabriel Detraz
parent 9fa82776cf
commit 6440ac48e8
4 changed files with 18 additions and 4 deletions

View file

@ -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

View file

@ -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',
],
},

View file

@ -101,9 +101,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<li><a href="{% url 'cotisations:index' %}"><i class="fa fa-eur"></i> {% trans "Manage the subscriptions" %}</a></li>
{% acl_end %}
{% comment %}
<li><a href="{% url 'tickets:aff-tickets' %}"><i class="fa fa-ticket"></i> {% trans "Tickets" %}</a></li>
{% endcomment %}
{% for template in optionnal_templates_navbar_list%}
{{ template }}
{% endfor %}
</ul>
</li>
{% acl_end %}

View file

@ -1,6 +1,7 @@
from django.contrib import messages
from django.shortcuts import render, redirect
from django.template.loader import render_to_string
from django.views.decorators.cache import cache_page
from django.urls import reverse
from django.forms import modelformset_factory
from re2o.views import form
@ -128,3 +129,7 @@ def preferences(request):
preferences = Preferences.objects.first()
context = {'preferences':preferences}
return render_to_string('tickets/preferences.html', context=context, request=request, using=None)
def navbar(request):
"""Vue cannonique d'affichage des tickets dans la navbar"""
return render_to_string('tickets/navbar.html')