From 87c32e6edc5017beade734cc0d9e06b5fcbacb50 Mon Sep 17 00:00:00 2001 From: 0livd <0livd@users.noreply.github.com> Date: Thu, 29 Jun 2017 18:05:25 +0200 Subject: [PATCH] Add a link to the dashboard in the nav bar It is only showed when ACTIVATE_DASHBOARD is set to True --- CHANGELOG.rst | 1 + budget/templates/layout.html | 3 +++ budget/web.py | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6ae16805..c913cd5c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 diff --git a/budget/templates/layout.html b/budget/templates/layout.html index 6ecff413..bb4153d0 100644 --- a/budget/templates/layout.html +++ b/budget/templates/layout.html @@ -70,6 +70,9 @@ {% endif %} + {% if g.is_dashboard_activated %} + + {% endif %} diff --git a/budget/web.py b/budget/web.py index 0d00cd11..e97857d4 100644 --- a/budget/web.py +++ b/budget/web.py @@ -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