added menu icons

This commit is contained in:
Arthur Gerbaud
2016-08-14 01:11:11 +02:00
parent 21ccaeb476
commit 219b68302e
3 changed files with 13 additions and 7 deletions

View File

@@ -5,6 +5,6 @@ class Config(AppConfig):
name = 'maraudes'
index_url = "/maraudes/"
menu_icon = "road"
def get_index_url(self):
return "/maraudes/"

View File

@@ -7,12 +7,17 @@ from django.template import Template, Context
from django.views.generic.base import ContextMixin, TemplateResponseMixin
## Utils ##
def get_apps(app_names):
APP_ICONS = {
'maraudes': 'road',
'suivi': 'eye-open',
}
def get_apps_config(app_names):
_apps = []
for name in app_names:
_apps.append(
apps.get_app_config(name)
)
app_config = apps.get_app_config(name)
app_config.menu_icon = APP_ICONS[name]
_apps.append(app_config)
return _apps
## Mixins ##
@@ -58,9 +63,10 @@ class WebsiteTemplateMixin(TemplateResponseMixin):
class Configuration:
stylesheets = ['base.css']
navbar_apps = ['maraudes', 'suivi']
apps = get_apps(navbar_apps)
apps = get_apps_config(navbar_apps)
page_blocks = ['header', 'header_small', 'title']
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._page_blocks = []

View File

@@ -13,7 +13,7 @@
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">{% for app in apps %}
<li {% if app == active_app %} class="active" {%endif%}>
<a href="/{{app.label}}/"><strong>{{ app.name|title }}</strong></a>
<a href="/{{app.label}}/">{% bootstrap_icon app.menu_icon %} &middot; <strong>{{ app.name|title }}</strong></a>
</li>
{% if app == active_app %}{% for t in app_menu %}{% include t %}{% endfor %}{% endif %}
{%endfor%}