From 6c115dfde0dafc936029eb9836e091985f9480d7 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Tue, 2 Nov 2021 16:17:12 +0100 Subject: [PATCH 1/4] misc: add get_absolute_url method to Role and User (#57955) --- src/authentic2/a2_rbac/models.py | 4 ++++ src/authentic2/custom_user/models.py | 4 ++++ src/authentic2/manager/tables.py | 2 -- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/authentic2/a2_rbac/models.py b/src/authentic2/a2_rbac/models.py index 484fd24c..a08cc309 100644 --- a/src/authentic2/a2_rbac/models.py +++ b/src/authentic2/a2_rbac/models.py @@ -21,6 +21,7 @@ from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError from django.core.validators import MinValueValidator from django.db import models +from django.urls import reverse from django.utils.text import slugify from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ @@ -376,6 +377,9 @@ class Role(RoleAbstractBase): return d + def get_absolute_url(self): + return reverse('a2-manager-role-members', kwargs={'pk': self.pk}) + Role._meta.natural_key = [ ['uuid'], diff --git a/src/authentic2/custom_user/models.py b/src/authentic2/custom_user/models.py index 7de79fa0..5863a7dc 100644 --- a/src/authentic2/custom_user/models.py +++ b/src/authentic2/custom_user/models.py @@ -22,6 +22,7 @@ import os from django.core.exceptions import MultipleObjectsReturned, ValidationError from django.core.mail import send_mail from django.db import models, transaction +from django.urls import reverse from django.utils import timezone from django.utils.translation import ugettext_lazy as _ @@ -425,6 +426,9 @@ class User(AbstractBaseUser, PermissionMixin): missing.append(attribute) return missing + def get_absolute_url(self): + return reverse('a2-manager-user-detail', kwargs={'pk': self.pk}) + class DeletedUser(models.Model): deleted = models.DateTimeField(verbose_name=_('Deletion date'), auto_now_add=True) diff --git a/src/authentic2/manager/tables.py b/src/authentic2/manager/tables.py index b0a123d5..20bcf311 100644 --- a/src/authentic2/manager/tables.py +++ b/src/authentic2/manager/tables.py @@ -66,12 +66,10 @@ class UserLinkColumn(PermissionLinkColumn): class UserTable(tables.Table): link = UserLinkColumn( - viewname='a2-manager-user-detail', permission='custom_user.view_user', verbose_name=_('User'), accessor='get_full_name', order_by=('last_name', 'first_name', 'email', 'username'), - kwargs={'pk': A('pk')}, ) username = tables.Column() email = VerifiableEmailColumn() -- 2.30.2