From 14fc0dd2fa44affb5eae1582f500a16d1a329cb8 Mon Sep 17 00:00:00 2001 From: Mohamed Nouffer Date: Sun, 24 Jul 2022 14:17:45 +0530 Subject: [PATCH] update --- rog/models.py | 8 ++++++-- rog/urls.py | 3 ++- rog/views.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/rog/models.py b/rog/models.py index 8373c7d..91e5b5b 100644 --- a/rog/models.py +++ b/rog/models.py @@ -93,7 +93,9 @@ class JpnAdminPerf(models.Model): managed = False db_table = 'jpn_admin_perf' - +### +### Cities +### class JpnSubPerf(models.Model): geom = models.MultiPolygonField(blank=True, null=True) adm0_en = models.CharField(max_length=254, blank=True, null=True) @@ -113,7 +115,9 @@ class JpnSubPerf(models.Model): managed = False db_table = 'jpn_sub_perf' - +### +### Gifu Areas +### class GifuAreas(models.Model): geom = models.MultiPolygonField(blank=True, null=True) adm0_en = models.CharField(max_length=254, blank=True, null=True) diff --git a/rog/urls.py b/rog/urls.py index d9e12ca..ad70cf7 100644 --- a/rog/urls.py +++ b/rog/urls.py @@ -1,6 +1,6 @@ from rest_framework import urlpatterns from rest_framework.routers import DefaultRouter -from .views import LocationViewSet, Location_lineViewSet, Location_polygonViewSet, Jpn_Main_PerfViewSet, Jpn_PerfViewSet, LocationsInPerf, SubInPerf, ExtentForSubPerf, SubPerfInMainPerf, ExtentForMainPerf, LocationsInSubPerf, CatView, RegistrationAPI, LoginAPI, UserAPI, UserActionViewset, UserMakeActionViewset, UserDestinations, UpdateOrder, LocationInBound, DeleteDestination, CustomAreaLocations, GetAllGifuAreas, CustomAreaNames, userDetials, UserTracksViewSet +from .views import LocationViewSet, Location_lineViewSet, Location_polygonViewSet, Jpn_Main_PerfViewSet, Jpn_PerfViewSet, LocationsInPerf, SubInPerf, ExtentForSubPerf, SubPerfInMainPerf, ExtentForMainPerf, LocationsInSubPerf, CatView, RegistrationAPI, LoginAPI, UserAPI, UserActionViewset, UserMakeActionViewset, UserDestinations, UpdateOrder, LocationInBound, DeleteDestination, CustomAreaLocations, GetAllGifuAreas, CustomAreaNames, userDetials, UserTracksViewSet, CatByCity from django.urls import path, include from knox import views as knox_views @@ -28,6 +28,7 @@ urlpatterns += [ path('perfext/', ExtentForSubPerf, name="sub_perf_ext"), path('mainperfext/', ExtentForMainPerf, name="main_perf_ext"), path('cats/', CatView, name='cats'), + path('catbycity/', CatByCity, name='cat_by_city'), path('register/', RegistrationAPI.as_view()), path('login/', LoginAPI.as_view()), path('user/', UserAPI.as_view()), diff --git a/rog/views.py b/rog/views.py index b6bdcb6..489e0d2 100644 --- a/rog/views.py +++ b/rog/views.py @@ -174,6 +174,18 @@ def CatView(request): return JsonResponse(serializer.data, safe=False) +def CatByCity(request): + city = request.GET.get('city') + if(city != None): + cilt_polygon = JpnSubPerf.objects.filter(adm1_ja=city) + cats = Location.objects.filter(geom__within=cilt_polygon[0].geom).values('category').distinct() + serializer = LocationCatSerializer(cats, many=True) + return JsonResponse(serializer.data, safe=False) + else: + return null + + + class RegistrationAPI(generics.GenericAPIView): serializer_class = CreateUserSerializer