fix - show org type by binary childs
This commit is contained in:
@@ -207,7 +207,7 @@ class ProvinceViewSet(SoftDeleteMixin, ModelViewSet):
|
||||
serializer_class = ProvinceSerializer
|
||||
|
||||
|
||||
class OrganizationTypeViewSet(SoftDeleteMixin, ModelViewSet):
|
||||
class OrganizationTypeViewSet(BaseViewSet, SoftDeleteMixin, ModelViewSet):
|
||||
""" Crud operations for Organization Type model """ #
|
||||
queryset = OrganizationType.objects.all()
|
||||
serializer_class = OrganizationTypeSerializer
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import typing
|
||||
|
||||
from apps.authentication.models import Organization
|
||||
from apps.authentication.models import Organization, OrganizationType
|
||||
|
||||
|
||||
def get_users_of_organization(org: Organization) -> typing.Any:
|
||||
@@ -28,3 +28,15 @@ def get_all_org_child(org: Organization = None) -> typing.Any:
|
||||
descendants.append(child)
|
||||
descendants.extend(get_all_org_child(child))
|
||||
return descendants
|
||||
|
||||
|
||||
def get_all_org_type_child(org_type: OrganizationType = None) -> typing.Any:
|
||||
"""
|
||||
get all child of an organization
|
||||
"""
|
||||
descendants = []
|
||||
children = org_type.children.all()
|
||||
for child in children:
|
||||
descendants.append(child)
|
||||
descendants.extend(get_all_org_type_child(child))
|
||||
return descendants
|
||||
|
||||
Reference in New Issue
Block a user