Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added WO4You URL #815

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion amelie/settings/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down Expand Up @@ -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/"
6 changes: 5 additions & 1 deletion amelie/tools/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion templates/basis.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@
<li><a href="{% url 'education:overview' %}">{% trans 'Information' %}</a></li>
<li><a href="{% url 'education:news_archive' %}">{% trans 'Education news' %}</a></li>
<li><a href="{% url 'education:event_overview' %}">{% trans 'Activities' %}</a></li>
<li><a href="https://wo4you.nl/">{% trans 'Books' %}</a></li>
{% if user.is_authenticated %}
<li><a href={{ request.book_sales_url }}>{% trans 'Books' %}</a></li>
{% else %}
<li><a href="https://wo4you.nl/">{% trans 'Books' %}</a></li>
{% endif %}
<li><a href="https://summaries.ia.utwente.nl/">{% trans 'Summaries' %}</a></li>
<li><a href="{% url 'education:complaints' %}">{% trans 'Complaints' %}</a></li>
<li><a href="{% url 'education:bouquet' %}">{% trans 'Educational bouquet' %}</a></li>
Expand Down
Loading