From 429627494c8eb6c068010d81e51a0c4b1543ab0c Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 8 Jul 2020 13:18:33 +0200 Subject: [PATCH] root: fix passbook.footer_links not being rendered --- passbook/core/templates/error/generic.html | 5 +++-- passbook/core/templates/login/denied.html | 5 +++-- passbook/flows/templates/flows/shell.html | 5 +++-- passbook/lib/config.py | 9 ++++++++- passbook/lib/default.yml | 4 +++- passbook/root/settings.py | 1 + 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/passbook/core/templates/error/generic.html b/passbook/core/templates/error/generic.html index 4f1753b3e..c25f9a061 100644 --- a/passbook/core/templates/error/generic.html +++ b/passbook/core/templates/error/generic.html @@ -46,10 +46,11 @@ diff --git a/passbook/core/templates/login/denied.html b/passbook/core/templates/login/denied.html index fd28cdd1b..2be7d36fa 100644 --- a/passbook/core/templates/login/denied.html +++ b/passbook/core/templates/login/denied.html @@ -51,10 +51,11 @@ diff --git a/passbook/flows/templates/flows/shell.html b/passbook/flows/templates/flows/shell.html index 8dbdba633..6aa9e855e 100644 --- a/passbook/flows/templates/flows/shell.html +++ b/passbook/flows/templates/flows/shell.html @@ -56,10 +56,11 @@ diff --git a/passbook/lib/config.py b/passbook/lib/config.py index a0f473d83..528ca91bf 100644 --- a/passbook/lib/config.py +++ b/passbook/lib/config.py @@ -3,11 +3,12 @@ import os from collections.abc import Mapping from contextlib import contextmanager from glob import glob -from typing import Any +from typing import Any, Dict from urllib.parse import urlparse import yaml from django.conf import ImproperlyConfigured +from django.http import HttpRequest from structlog import get_logger SEARCH_PATHS = ["passbook/lib/default.yml", "/etc/passbook/config.yml", ""] + glob( @@ -18,6 +19,12 @@ ENV_PREFIX = "PASSBOOK" ENVIRONMENT = os.getenv(f"{ENV_PREFIX}_ENV", "local") +def context_processor(request: HttpRequest) -> Dict[str, Any]: + """Context Processor that injects config object into every template""" + kwargs = {"config": CONFIG.raw} + return kwargs + + class ConfigLoader: """Search through SEARCH_PATHS and load configuration. Environment variables starting with `ENV_PREFIX` are also applied. diff --git a/passbook/lib/default.yml b/passbook/lib/default.yml index 9fe1add99..a6b74cb87 100644 --- a/passbook/lib/default.yml +++ b/passbook/lib/default.yml @@ -18,7 +18,9 @@ log_level: warning error_reporting: false passbook: + # Optionally add links to the footer on the login page footer_links: - # Optionally add links to the footer on the login page + - name: Documentation + href: https://passbook.beryju.org/ # - name: test # href: https://test diff --git a/passbook/root/settings.py b/passbook/root/settings.py index 009a286d0..1c1d5d0f6 100644 --- a/passbook/root/settings.py +++ b/passbook/root/settings.py @@ -181,6 +181,7 @@ TEMPLATES = [ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "passbook.lib.config.context_processor", ], }, },