From 80b82e080f52d13a113daf4eaed31898eea1036c Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 11 Jun 2015 17:31:10 +0200 Subject: [PATCH] attributes_ng/sources: service_roles source does not get inherited service roles (fixes #7546) The call to filter(service=service) must be done after the call to for_user(user), otherwise we only get inherited roles of services roles, which means none. --- src/authentic2/attributes_ng/sources/service_roles.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/authentic2/attributes_ng/sources/service_roles.py b/src/authentic2/attributes_ng/sources/service_roles.py index 64fdd26..a6c74e9 100644 --- a/src/authentic2/attributes_ng/sources/service_roles.py +++ b/src/authentic2/attributes_ng/sources/service_roles.py @@ -38,8 +38,9 @@ def get_attributes(instance, ctx): if not user or not service: return ctx = ctx.copy() - roles = Role.objects.filter(service=service) \ - .for_user(user).prefetch_related('attributes') + roles = Role.objects.for_user(user) \ + .filter(service=service) \ + .prefetch_related('attributes') for service_role in roles: for service_role_attribute in service_role.attributes.all(): name = service_role_attribute.name -- 2.1.4