Skip to content

Commit

Permalink
Merge pull request #1427 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
org api fix
  • Loading branch information
adnankattekaden authored Oct 26, 2023
2 parents 1314404 + c30c4e4 commit b529fa2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
35 changes: 35 additions & 0 deletions api/dashboard/location/location_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,38 @@ def delete(self, request, district_id):
general_message="District deleted successfully"
).get_success_response()


class CountryListApi(APIView):
def get(self, request):
country = Country.objects.all().values(
'id',
'name'
).order_by('name')

return CustomResponse(
response=country
).get_success_response()


class StateListApi(APIView):
def get(self, request):
state = State.objects.all().values(
'id',
'name'
).order_by('name')

return CustomResponse(
response=state
).get_success_response()


class ZoneListApi(APIView):
def get(self, request):
zone = Zone.objects.all().values(
'id',
'name'
).order_by('name')

return CustomResponse(
response=zone
).get_success_response()
3 changes: 3 additions & 0 deletions api/dashboard/location/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
# app_name will help us do a reverse look-up latter.
urlpatterns = [
path('countries/', location_views.CountryDataAPI.as_view()),
path('countries/list/', location_views.CountryListApi.as_view()),
path('countries/<str:country_id>/', location_views.CountryDataAPI.as_view()),

path('states/', location_views.StateDataAPI.as_view()),
path('states/list/', location_views.StateListApi.as_view()),
path('states/<str:state_id>/', location_views.StateDataAPI.as_view()),

path('zones/', location_views.ZoneDataAPI.as_view()),
path('zones/list/', location_views.ZoneListApi.as_view()),
path('zones/<str:zone_id>/', location_views.ZoneDataAPI.as_view()),

path('districts/', location_views.DistrictDataAPI.as_view()),
Expand Down
11 changes: 6 additions & 5 deletions api/dashboard/organisation/organisation_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ def get(self, request, org_type, district_id=None):
)

org_queryset = organisations.select_related(
"affiliation",
"district__zone__state__country",
"district__zone__state",
"district__zone",
"district",
'affiliation',
# 'district',
# "district__zone__state__country",
# "district__zone__state",
# "district__zone",
# "district",
).prefetch_related(
Prefetch(
"user_organization_link_org",
Expand Down

0 comments on commit b529fa2

Please sign in to comment.