root: fix passbook.footer_links not being rendered

This commit is contained in:
Jens Langhammer 2020-07-08 13:18:33 +02:00
parent 9feea155fe
commit 429627494c
6 changed files with 21 additions and 8 deletions

View File

@ -46,10 +46,11 @@
<footer class="pf-c-login__footer">
<p></p>
<ul class="pf-c-list pf-m-inline">
{% for link in config.passbook.footer_links %}
<li>
<a href="https://passbook.beryju.org/">{% trans 'Documentation' %}</a>
<a href="{{ link.href }}">{{ link.name }}</a>
</li>
<!-- TODO:load config.passbook.footer.links -->
{% endfor %}
</ul>
</footer>
</div>

View File

@ -51,10 +51,11 @@
<footer class="pf-c-login__footer">
<p></p>
<ul class="pf-c-list pf-m-inline">
{% for link in config.passbook.footer_links %}
<li>
<a href="https://passbook.beryju.org/">{% trans 'Documentation' %}</a>
<a href="{{ link.href }}">{{ link.name }}</a>
</li>
<!-- TODO: load config.passbook.footer.links -->
{% endfor %}
</ul>
</footer>
</div>

View File

@ -56,10 +56,11 @@
<footer class="pf-c-login__footer">
<p></p>
<ul class="pf-c-list pf-m-inline">
{% for link in config.passbook.footer_links %}
<li>
<a href="https://passbook.beryju.org/">{% trans 'Documentation' %}</a>
<a href="{{ link.href }}">{{ link.name }}</a>
</li>
<!-- TODO:load config.passbook.footer.links -->
{% endfor %}
</ul>
</footer>
</div>

View File

@ -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.

View File

@ -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

View File

@ -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",
],
},
},