Add a link to the dashboard in the nav bar

It is only showed when ACTIVATE_DASHBOARD
is set to True
This commit is contained in:
0livd 2017-06-29 18:05:25 +02:00
parent d8107d449d
commit 87c32e6edc
3 changed files with 12 additions and 0 deletions

View file

@ -20,6 +20,7 @@ This document describes changes between each past release.
- With admin credentials, one can access every project
- Add delete and edit project actions in the dashboard
- Add a new setting to activate the dashboard (ACTIVATE_DASHBOARD)
- Add a link to the dashboard in the navigation bar when it is activated
### Removed

View file

@ -70,6 +70,9 @@
{% endif %}
<li class="nav-item{% if g.lang == "fr" %} active{% endif %}"><a class="nav-link" href="{{ url_for(".change_lang", lang="fr") }}">fr</a></li>
<li class="nav-item{% if g.lang == "en" %} active{% endif %}"><a class="nav-link" href="{{ url_for(".change_lang", lang="en") }}">en</a></li>
{% if g.is_dashboard_activated %}
<li class="nav-item{% if request.url_rule.endpoint == "main.dashboard" %} active{% endif %}"><a class="nav-link" href="{{ url_for(".dashboard") }}">{{ _("Dashboard") }}</a></li>
{% endif %}
</ul>
</div>
</nav>

View file

@ -68,6 +68,14 @@ def add_project_id(endpoint, values):
values['project_id'] = g.project.id
@main.url_value_preprocessor
def set_is_dashboard_activated(endpoint, values):
"""Set is_dashboard_activated application wide
so this variable can be used in the layout template
"""
g.is_dashboard_activated = current_app.config["ACTIVATE_DASHBOARD"]
@main.url_value_preprocessor
def pull_project(endpoint, values):
"""When a request contains a project_id value, transform it directly