set userrealtion & organization to list of their childs - BaseVewSet
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import typing
|
||||
|
||||
from apps.authentication.models import Organization
|
||||
|
||||
|
||||
@@ -15,3 +16,15 @@ def get_users_of_organization(org: Organization) -> typing.Any:
|
||||
} for rel in user_relations]
|
||||
|
||||
return users_list
|
||||
|
||||
|
||||
def get_all_org_child(org: Organization = None) -> typing.Any:
|
||||
"""
|
||||
get all child of an organization
|
||||
"""
|
||||
descendants = []
|
||||
children = org.parents.all()
|
||||
for child in children:
|
||||
descendants.append(child)
|
||||
descendants.extend(get_all_org_child(child))
|
||||
return descendants
|
||||
|
||||
Reference in New Issue
Block a user