From ae58b88707cd15e0f4beefab0855a035ea636111 Mon Sep 17 00:00:00 2001 From: Maxime Bombar Date: Mon, 2 Jul 2018 12:56:49 +0200 Subject: [PATCH] Printer app really is optionnal --- re2o/context_processors.py | 11 ++++++++++- templates/base.html | 10 +++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/re2o/context_processors.py b/re2o/context_processors.py index 6beac564..feae6b36 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -30,6 +30,7 @@ from django.http import HttpRequest from preferences.models import GeneralOption, OptionalMachine from django.utils.translation import get_language +from re2o.settings import INSTALLED_APPS def context_user(request): """Fonction de context lorsqu'un user est logué (ou non), @@ -57,7 +58,6 @@ def context_user(request): 'ipv6_enabled': OptionalMachine.get_cached_value('ipv6'), } - def date_now(request): """Add the current date in the context for quick informations and comparisons""" @@ -65,3 +65,12 @@ def date_now(request): 'now_aware': datetime.datetime.now(datetime.timezone.utc), 'now_naive': datetime.datetime.now() } + +def context_printer(request): + """ + Useful to know whether the printer app is activated or not + """ + printer = 'printer' in INSTALLED_APPS + return { + 'printer': printer, + } diff --git a/templates/base.html b/templates/base.html index 76ba975a..0599cd11 100644 --- a/templates/base.html +++ b/templates/base.html @@ -101,6 +101,14 @@ with this program; if not, write to the Free Software Foundation, Inc., {% acl_end %} + {% if printer %} + + {% endif %} {% can_view_app logs %}
  • {% trans "Statistics" %}
  • {% acl_end %} @@ -121,7 +129,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if not request.user.is_authenticated %} - {% if var_sa %} + {% if var_sa %}
  • {% trans "Sign up" %}