From b6fea6f7e21f96aef9f8de3bf9b47e9fd3470c7b Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 9 May 2022 15:59:43 +0200 Subject: [PATCH 4/9] rbac: add slug and name as implicit natural keys (#62013) If the natural key is not precise enough, MultipleObjectReturned will be raised preventing mismatches. But it will help using the API for simple cases where the name is globally unique. --- src/authentic2/a2_rbac/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/authentic2/a2_rbac/models.py b/src/authentic2/a2_rbac/models.py index 6b937b73..88b32ccf 100644 --- a/src/authentic2/a2_rbac/models.py +++ b/src/authentic2/a2_rbac/models.py @@ -454,6 +454,12 @@ Role._meta.natural_key = [ ['name', 'ou', 'service'], ['slug', 'ou', 'service__isnull'], ['name', 'ou', 'service__isnull'], + ['slug', 'ou__isnull'], + ['name', 'ou__isnull'], + ['slug', 'ou'], + ['name', 'ou'], + ['slug'], + ['name'], ] -- 2.35.1