|
|
|
@ -188,7 +188,8 @@ class PlacementPointViewSet(ReadOnlyModelViewSet):
|
|
|
|
def get_queryset(self):
|
|
|
|
def get_queryset(self):
|
|
|
|
qs = self.queryset.all()
|
|
|
|
qs = self.queryset.all()
|
|
|
|
location_ids = self.request.GET.get('location_ids[]')
|
|
|
|
location_ids = self.request.GET.get('location_ids[]')
|
|
|
|
prediction = self.request.GET.get('prediction[]')
|
|
|
|
prediction_first = self.request.GET.get('prediction_first[]')
|
|
|
|
|
|
|
|
prediction_current = self.request.GET.get('prediction_current[]')
|
|
|
|
categories = self.request.GET.get('categories[]')
|
|
|
|
categories = self.request.GET.get('categories[]')
|
|
|
|
status = self.request.GET.get('status[]')
|
|
|
|
status = self.request.GET.get('status[]')
|
|
|
|
delta = self.request.GET.get('delta[]')
|
|
|
|
delta = self.request.GET.get('delta[]')
|
|
|
|
@ -196,12 +197,17 @@ class PlacementPointViewSet(ReadOnlyModelViewSet):
|
|
|
|
age = self.request.GET.get('age[]')
|
|
|
|
age = self.request.GET.get('age[]')
|
|
|
|
included = self.request.GET.get('included[]')
|
|
|
|
included = self.request.GET.get('included[]')
|
|
|
|
excluded = self.request.GET.get('excluded[]')
|
|
|
|
excluded = self.request.GET.get('excluded[]')
|
|
|
|
|
|
|
|
plan_first = self.request.GET.get('plan_first[]')
|
|
|
|
|
|
|
|
plan_current = self.request.GET.get('plan_current[]')
|
|
|
|
if location_ids:
|
|
|
|
if location_ids:
|
|
|
|
location_ids = list(location_ids.split(','))
|
|
|
|
location_ids = list(location_ids.split(','))
|
|
|
|
qs = qs.filter(location_id__in=location_ids)
|
|
|
|
qs = qs.filter(location_id__in=location_ids)
|
|
|
|
if prediction:
|
|
|
|
if prediction_first:
|
|
|
|
prediction = list(prediction.split(','))
|
|
|
|
prediction_first = list(prediction_first.split(','))
|
|
|
|
qs = qs.filter(prediction__range=prediction)
|
|
|
|
qs = qs.filter(prediction_first__range=prediction_first)
|
|
|
|
|
|
|
|
if prediction_current:
|
|
|
|
|
|
|
|
prediction_current = list(prediction_current.split(','))
|
|
|
|
|
|
|
|
qs = qs.filter(prediction_current__range=prediction_current)
|
|
|
|
if categories:
|
|
|
|
if categories:
|
|
|
|
categories = list(categories.split(','))
|
|
|
|
categories = list(categories.split(','))
|
|
|
|
qs = qs.filter(category__in=categories)
|
|
|
|
qs = qs.filter(category__in=categories)
|
|
|
|
@ -217,6 +223,12 @@ class PlacementPointViewSet(ReadOnlyModelViewSet):
|
|
|
|
if age:
|
|
|
|
if age:
|
|
|
|
age = list(age.split(','))
|
|
|
|
age = list(age.split(','))
|
|
|
|
qs = qs.filter(age__range=age)
|
|
|
|
qs = qs.filter(age__range=age)
|
|
|
|
|
|
|
|
if plan_first:
|
|
|
|
|
|
|
|
plan_first = list(plan_first.split(','))
|
|
|
|
|
|
|
|
qs = qs.filter(plan_first__range=plan_first)
|
|
|
|
|
|
|
|
if plan_current:
|
|
|
|
|
|
|
|
plan_current = list(plan_current.split(','))
|
|
|
|
|
|
|
|
qs = qs.filter(plan_current__range=plan_current)
|
|
|
|
if excluded:
|
|
|
|
if excluded:
|
|
|
|
excluded = list(excluded.split(','))
|
|
|
|
excluded = list(excluded.split(','))
|
|
|
|
qs = qs.filter(~Q(location_id__in=excluded))
|
|
|
|
qs = qs.filter(~Q(location_id__in=excluded))
|
|
|
|
@ -299,7 +311,10 @@ class update_status(APIView):
|
|
|
|
qs = models.PlacementPoint.objects.all()
|
|
|
|
qs = models.PlacementPoint.objects.all()
|
|
|
|
new_status = self.request.GET.get('status')
|
|
|
|
new_status = self.request.GET.get('status')
|
|
|
|
location_ids = self.request.GET.get('location_ids[]')
|
|
|
|
location_ids = self.request.GET.get('location_ids[]')
|
|
|
|
prediction = self.request.GET.get('prediction[]')
|
|
|
|
prediction_first = self.request.GET.get('prediction_first[]')
|
|
|
|
|
|
|
|
prediction_current = self.request.GET.get('prediction_current[]')
|
|
|
|
|
|
|
|
plan_first = self.request.GET.get('plan_first[]')
|
|
|
|
|
|
|
|
plan_current = self.request.GET.get('plan_current[]')
|
|
|
|
categories = self.request.GET.get('categories[]')
|
|
|
|
categories = self.request.GET.get('categories[]')
|
|
|
|
status = self.request.GET.get('status[]')
|
|
|
|
status = self.request.GET.get('status[]')
|
|
|
|
delta = self.request.GET.get('delta[]')
|
|
|
|
delta = self.request.GET.get('delta[]')
|
|
|
|
@ -309,14 +324,23 @@ class update_status(APIView):
|
|
|
|
excluded = self.request.GET.get('excluded[]')
|
|
|
|
excluded = self.request.GET.get('excluded[]')
|
|
|
|
if not new_status:
|
|
|
|
if not new_status:
|
|
|
|
return Response({'message': 'No status provided'}, status=http_status.HTTP_400_BAD_REQUEST)
|
|
|
|
return Response({'message': 'No status provided'}, status=http_status.HTTP_400_BAD_REQUEST)
|
|
|
|
if not any([location_ids, prediction, categories, status, delta, fact, age]):
|
|
|
|
if not any([location_ids, prediction_first,plan_first,plan_current,prediction_current, categories, status, delta, fact, age]):
|
|
|
|
qs = models.PlacementPoint.objects.none()
|
|
|
|
qs = models.PlacementPoint.objects.none()
|
|
|
|
if location_ids:
|
|
|
|
if location_ids:
|
|
|
|
location_ids = list(location_ids.split(','))
|
|
|
|
location_ids = list(location_ids.split(','))
|
|
|
|
qs = qs.filter(location_id__in=location_ids)
|
|
|
|
qs = qs.filter(location_id__in=location_ids)
|
|
|
|
if prediction:
|
|
|
|
if prediction_first:
|
|
|
|
prediction = list(prediction.split(','))
|
|
|
|
prediction_first = list(prediction_first.split(','))
|
|
|
|
qs = qs.filter(prediction__range=prediction)
|
|
|
|
qs = qs.filter(prediction_first__range=prediction_first)
|
|
|
|
|
|
|
|
if prediction_current:
|
|
|
|
|
|
|
|
prediction_current = list(prediction_current.split(','))
|
|
|
|
|
|
|
|
qs = qs.filter(prediction_current__range=prediction_current)
|
|
|
|
|
|
|
|
if plan_first:
|
|
|
|
|
|
|
|
plan_first = list(plan_first.split(','))
|
|
|
|
|
|
|
|
qs = qs.filter(plan_first__range=plan_first)
|
|
|
|
|
|
|
|
if plan_current:
|
|
|
|
|
|
|
|
plan_current = list(plan_current.split(','))
|
|
|
|
|
|
|
|
qs = qs.filter(plan_current__range=plan_current)
|
|
|
|
if categories:
|
|
|
|
if categories:
|
|
|
|
categories = list(categories.split(','))
|
|
|
|
categories = list(categories.split(','))
|
|
|
|
qs = qs.filter(category__in=categories)
|
|
|
|
qs = qs.filter(category__in=categories)
|
|
|
|
@ -339,7 +363,7 @@ class update_status(APIView):
|
|
|
|
inclded = list(included.split(','))
|
|
|
|
inclded = list(included.split(','))
|
|
|
|
qs2 = models.PlacementPoint.objects.filter(location_id__in=inclded).all()
|
|
|
|
qs2 = models.PlacementPoint.objects.filter(location_id__in=inclded).all()
|
|
|
|
qs = (qs | qs2).distinct()
|
|
|
|
qs = (qs | qs2).distinct()
|
|
|
|
if not any([location_ids, prediction, categories, status, delta, fact, age, excluded, included]):
|
|
|
|
if not any([location_ids, prediction_first,plan_first,plan_current,prediction_current, categories, status, delta, fact, age, excluded, included]):
|
|
|
|
return Response({'message': 'Empty queryset'}, status=http_status.HTTP_200_OK)
|
|
|
|
return Response({'message': 'Empty queryset'}, status=http_status.HTTP_200_OK)
|
|
|
|
|
|
|
|
|
|
|
|
qs.update(**{'status': new_status})
|
|
|
|
qs.update(**{'status': new_status})
|
|
|
|
|