From b11c7ecc210177328793628074d875d4b79dbec2 Mon Sep 17 00:00:00 2001 From: Tobias Kunze Date: Wed, 19 Mar 2025 17:36:20 +0100 Subject: [PATCH] Link keycloak on profile page --- .../frontend/templates/frontend/profile.html | 91 +++++++++++++------ src/servala/frontend/views/generic.py | 12 +++ 2 files changed, 73 insertions(+), 30 deletions(-) diff --git a/src/servala/frontend/templates/frontend/profile.html b/src/servala/frontend/templates/frontend/profile.html index a6f7021..9532e96 100644 --- a/src/servala/frontend/templates/frontend/profile.html +++ b/src/servala/frontend/templates/frontend/profile.html @@ -1,5 +1,5 @@ {% extends "frontend/base.html" %} -{% load i18n %} +{% load i18n static %} {% block html_title %} {% block page_title %} {% translate "Profile" %} @@ -10,32 +10,63 @@

{% translate "Account" %}

{% endblock %} -{% block card_content %} -

- {% blocktranslate trimmed %} - You are logged in with your VSHN user account. You will be able to change your password and other settings here in the future. - {% endblocktranslate %} -

-
- - - - - - - - - - - - - - - - - - - -
{% translate "E-mail" %}{{ request.user.email }}
{% translate "First name" %}{{ request.user.first_name }}
{% translate "Last name" %}{{ request.user.last_name }}
{% translate "Company" %}{{ request.user.company }}
-
-{% endblock card_content %} +{% block content %} +
+
+
+
+
+

{% translate "Profile" %}

+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
{% translate "E-mail" %}{{ request.user.email }}
{% translate "First name" %}{{ request.user.first_name }}
{% translate "Last name" %}{{ request.user.last_name }}
{% translate "Company" %}{{ request.user.company }}
+
+
+
+
+
+
+
+
+

{% translate "Account" %}

+
+
+
+

+ {% blocktranslate trimmed %} + You are logged in with your VSHN user account. Change your password and other account data here: + {% endblocktranslate %} +

+ + + {% translate "VSHN Account" %} + +
+
+
+
+
+
+{% endblock content %} diff --git a/src/servala/frontend/views/generic.py b/src/servala/frontend/views/generic.py index 8b0271e..3b2196b 100644 --- a/src/servala/frontend/views/generic.py +++ b/src/servala/frontend/views/generic.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.views.generic import TemplateView @@ -7,3 +8,14 @@ class IndexView(TemplateView): class ProfileView(TemplateView): template_name = "frontend/profile.html" + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + keycloak_server_url = settings.SOCIALACCOUNT_PROVIDERS["openid_connect"][ + "APPS" + ][0]["settings"]["server_url"] + account_url = keycloak_server_url.replace( + "/.well-known/openid-configuration", "/account" + ) + context["account_href"] = account_url + return context