From 3bf070fdcab25815710b60ef4a555eee63a5bfb1 Mon Sep 17 00:00:00 2001 From: Daniel jonker Date: Mon, 30 Oct 2023 22:32:13 +0100 Subject: [PATCH] Changed middleware to add wo4you book url --- amelie/settings/generic.py | 5 ++++- amelie/tools/middleware.py | 6 +++++- templates/basis.html | 6 +++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/amelie/settings/generic.py b/amelie/settings/generic.py index 7ebc1e0..eca74e5 100644 --- a/amelie/settings/generic.py +++ b/amelie/settings/generic.py @@ -202,7 +202,7 @@ 'django.contrib.admindocs.middleware.XViewMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'amelie.tools.middleware.PersonMiddleware', # Adds person, is_board, is_education_committee attributes to request + 'amelie.tools.middleware.GlobalIAVariablesMiddleware', # Adds person, is_board, is_education_committee attributes to request 'auditlog.middleware.AuditlogMiddleware', 'mozilla_django_oidc.middleware.SessionRefresh', # Verify OIDC session tokens ] @@ -901,3 +901,6 @@ KEYCLOAK_API_CLIENT_SECRET = "" KEYCLOAK_API_AUTHN_ENDPOINT = "https://auth.ia.utwente.nl/realms/inter-actief/protocol/openid-connect/token" KEYCLOAK_PROVIDERS_UNLINK_ALLOWED = ['github', 'google', 'linkedin'] + +# Wo4you personal URL +BOOK_SALES_URL = "https://wo4you.nl/" \ No newline at end of file diff --git a/amelie/tools/middleware.py b/amelie/tools/middleware.py index 2d02b0a..3da3690 100644 --- a/amelie/tools/middleware.py +++ b/amelie/tools/middleware.py @@ -2,6 +2,7 @@ from django.template import loader from django.utils import translation from django.utils.deprecation import MiddlewareMixin +from django.conf import settings class HttpResponseNotAllowedMiddleware(MiddlewareMixin): @@ -19,13 +20,16 @@ def process_response(self, request, response): return response -class PersonMiddleware(MiddlewareMixin): +class GlobalIAVariablesMiddleware(MiddlewareMixin): """ Ties handy functions to the request. + This class is designated for passing global Inter-Actief vairables to the frontend. """ # noinspection PyMethodMayBeStatic def process_request(self, request): + request.book_sales_url = settings.BOOK_SALES_URL + user = request.user if hasattr(user, 'person'): request.person = request.user.person diff --git a/templates/basis.html b/templates/basis.html index 4980c7d..846f70a 100644 --- a/templates/basis.html +++ b/templates/basis.html @@ -226,7 +226,11 @@
  • {% trans 'Information' %}
  • {% trans 'Education news' %}
  • {% trans 'Activities' %}
  • -
  • {% trans 'Books' %}
  • + {% if user.is_authenticated %} +
  • {% trans 'Books' %}
  • + {% else %} +
  • {% trans 'Books' %}
  • + {% endif %}
  • {% trans 'Summaries' %}
  • {% trans 'Complaints' %}
  • {% trans 'Educational bouquet' %}