This commit is contained in:
Mohamed Nouffer
2022-07-24 14:17:45 +05:30
parent 835947cd58
commit 14fc0dd2fa
3 changed files with 20 additions and 3 deletions

View File

@ -93,7 +93,9 @@ class JpnAdminPerf(models.Model):
managed = False managed = False
db_table = 'jpn_admin_perf' db_table = 'jpn_admin_perf'
###
### Cities
###
class JpnSubPerf(models.Model): class JpnSubPerf(models.Model):
geom = models.MultiPolygonField(blank=True, null=True) geom = models.MultiPolygonField(blank=True, null=True)
adm0_en = models.CharField(max_length=254, 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 managed = False
db_table = 'jpn_sub_perf' db_table = 'jpn_sub_perf'
###
### Gifu Areas
###
class GifuAreas(models.Model): class GifuAreas(models.Model):
geom = models.MultiPolygonField(blank=True, null=True) geom = models.MultiPolygonField(blank=True, null=True)
adm0_en = models.CharField(max_length=254, blank=True, null=True) adm0_en = models.CharField(max_length=254, blank=True, null=True)

View File

@ -1,6 +1,6 @@
from rest_framework import urlpatterns from rest_framework import urlpatterns
from rest_framework.routers import DefaultRouter 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 django.urls import path, include
from knox import views as knox_views from knox import views as knox_views
@ -28,6 +28,7 @@ urlpatterns += [
path('perfext/', ExtentForSubPerf, name="sub_perf_ext"), path('perfext/', ExtentForSubPerf, name="sub_perf_ext"),
path('mainperfext/', ExtentForMainPerf, name="main_perf_ext"), path('mainperfext/', ExtentForMainPerf, name="main_perf_ext"),
path('cats/', CatView, name='cats'), path('cats/', CatView, name='cats'),
path('catbycity/', CatByCity, name='cat_by_city'),
path('register/', RegistrationAPI.as_view()), path('register/', RegistrationAPI.as_view()),
path('login/', LoginAPI.as_view()), path('login/', LoginAPI.as_view()),
path('user/', UserAPI.as_view()), path('user/', UserAPI.as_view()),

View File

@ -174,6 +174,18 @@ def CatView(request):
return JsonResponse(serializer.data, safe=False) 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): class RegistrationAPI(generics.GenericAPIView):
serializer_class = CreateUserSerializer serializer_class = CreateUserSerializer