Files

16 lines
353 B
Python
Raw Permalink Normal View History

2025-10-28 09:39:22 +03:30
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)
2025-10-28 09:51:30 +03:30
descendants.extend(get_all_role_child(child))
2025-10-28 09:39:22 +03:30
return descendants