From febf5fa98b303765d4d140dd6d754a13189e71e8 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand <benjamin.bertrand@esss.se> Date: Wed, 13 Dec 2017 11:07:39 +0100 Subject: [PATCH] Display CSEntry groups in profile There is no point displaying the LDAP groups in the profile --- app/models.py | 8 ++++++++ app/templates/users/profile.html | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models.py b/app/models.py index 73c0589..46f4578 100644 --- a/app/models.py +++ b/app/models.py @@ -106,6 +106,14 @@ class User(db.Model, UserMixin): """ return str(self.id) + @property + def csentry_groups(self): + groups = [] + for key, value in current_app.config['CSENTRY_LDAP_GROUPS'].items(): + if value in self.groups: + groups.append(key) + return groups + @property def is_admin(self): return current_app.config['CSENTRY_LDAP_GROUPS']['admin'] in self.groups diff --git a/app/templates/users/profile.html b/app/templates/users/profile.html index a05fb01..7660716 100644 --- a/app/templates/users/profile.html +++ b/app/templates/users/profile.html @@ -25,8 +25,8 @@ <dd>{{user.name}}</dd> <dt>Email</dt> <dd>{{user.email}}</dd> - <dt>Groups</dt> - <dd>{{ user.groups | join(', ') }}</dd> + <dt>CSEntry Groups</dt> + <dd>{{ user.csentry_groups | join(', ') }}</dd> </dl> <h3>Personal access tokens</h3> -- GitLab