role childs service add to BaseViewSet

This commit is contained in:
2025-10-28 09:39:22 +03:30
parent 1204fad1a0
commit 714e9abc1c
4 changed files with 34 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
import typing
from apps.authorization.models import Role
def get_all_role_child(role: Role = None) -> typing.Any:
"""
get all child of an role
"""
descendants = []
children = role.child.all()
for child in children:
descendants.append(child)
descendants.extend(get_all_org_child(child))
return descendants