|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import json
|
|
|
|
|
import warnings
|
|
|
|
|
from io import BytesIO
|
|
|
|
|
|
|
|
|
|
import pandas as pd
|
|
|
|
|
@ -6,6 +7,7 @@ from django.core.cache import cache
|
|
|
|
|
from django.db.models import Q
|
|
|
|
|
from django.http import HttpResponse
|
|
|
|
|
from rest_framework import permissions, status
|
|
|
|
|
from rest_framework import status as http_status
|
|
|
|
|
from rest_framework.decorators import action
|
|
|
|
|
from rest_framework.generics import GenericAPIView
|
|
|
|
|
from rest_framework.response import Response
|
|
|
|
|
@ -273,16 +275,13 @@ class PlacementPointViewSet(ReadOnlyModelViewSet):
|
|
|
|
|
return Response(data, status=status.HTTP_200_OK)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import warnings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class refresh_placement_points(APIView):
|
|
|
|
|
@staticmethod
|
|
|
|
|
def post(request):
|
|
|
|
|
warnings.filterwarnings('ignore')
|
|
|
|
|
file = request.FILES['file']
|
|
|
|
|
load_data(file)
|
|
|
|
|
return Response(200)
|
|
|
|
|
return Response(status=http_status.HTTP_200_OK)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class load_ao_and_rayons(APIView):
|
|
|
|
|
@ -292,7 +291,7 @@ class load_ao_and_rayons(APIView):
|
|
|
|
|
file_ao = request.FILES['file_ao']
|
|
|
|
|
file_rayon = request.FILES['file_rayon']
|
|
|
|
|
utils.load_ao_and_rayons(file_ao, file_rayon)
|
|
|
|
|
return Response(200)
|
|
|
|
|
return Response(status=http_status.HTTP_200_OK)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class update_status(APIView):
|
|
|
|
|
@ -308,6 +307,8 @@ class update_status(APIView):
|
|
|
|
|
age = self.request.GET.get('age[]')
|
|
|
|
|
included = self.request.GET.get('included[]')
|
|
|
|
|
excluded = self.request.GET.get('excluded[]')
|
|
|
|
|
if not new_status:
|
|
|
|
|
return Response({'message': 'No status provided'}, status=http_status.HTTP_400_BAD_REQUEST)
|
|
|
|
|
if not any([location_ids, prediction, categories, status, delta, fact, age]):
|
|
|
|
|
qs = models.PlacementPoint.objects.none()
|
|
|
|
|
if location_ids:
|
|
|
|
|
@ -339,6 +340,7 @@ class update_status(APIView):
|
|
|
|
|
qs2 = models.PlacementPoint.objects.filter(location_id__in=inclded).all()
|
|
|
|
|
qs = (qs | qs2).distinct()
|
|
|
|
|
if not any([location_ids, prediction, categories, status, delta, fact, age, excluded, included]):
|
|
|
|
|
return Response(200)
|
|
|
|
|
return Response({'message': 'Empty queryset'}, status=http_status.HTTP_200_OK)
|
|
|
|
|
|
|
|
|
|
qs.update(**{'status': new_status})
|
|
|
|
|
return Response(200)
|
|
|
|
|
return Response({'message': 'status updated'}, status=http_status.HTTP_200_OK)
|
|
|
|
|
|