role childs service add to BaseViewSet
This commit is contained in:
15
apps/authorization/services/role_child.py
Normal file
15
apps/authorization/services/role_child.py
Normal 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
|
||||
Reference in New Issue
Block a user