diff --git a/api/dashboard/location/location_views.py b/api/dashboard/location/location_views.py index c7a4d99e..cc15bf2a 100644 --- a/api/dashboard/location/location_views.py +++ b/api/dashboard/location/location_views.py @@ -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() diff --git a/api/dashboard/location/urls.py b/api/dashboard/location/urls.py index 290f9b67..110de27d 100644 --- a/api/dashboard/location/urls.py +++ b/api/dashboard/location/urls.py @@ -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//', location_views.CountryDataAPI.as_view()), path('states/', location_views.StateDataAPI.as_view()), + path('states/list/', location_views.StateListApi.as_view()), path('states//', location_views.StateDataAPI.as_view()), path('zones/', location_views.ZoneDataAPI.as_view()), + path('zones/list/', location_views.ZoneListApi.as_view()), path('zones//', location_views.ZoneDataAPI.as_view()), path('districts/', location_views.DistrictDataAPI.as_view()), diff --git a/api/dashboard/organisation/organisation_views.py b/api/dashboard/organisation/organisation_views.py index e6225114..7467b7c6 100644 --- a/api/dashboard/organisation/organisation_views.py +++ b/api/dashboard/organisation/organisation_views.py @@ -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",