Example #1
0
 def list(self, request, *args, **kwargs):
     try:
         min_lat, max_lat, min_long, max_long = get_limits(request)
         start_date, end_date = get_start_and_end_dates(request)
     except ValueError:
         return Response(status=status.HTTP_400_BAD_REQUEST)
     else:
         queryset = self.get_queryset().filter(coordinates__latitude__range=(min_lat, max_lat))
         queryset = queryset.filter(coordinates__longitude__range=(min_long, max_long))
         queryset = queryset.filter(timestamp__range=(start_date, end_date))
         serializer = QuakeSerializer(queryset, many=True)
         return Response(serializer.data)
Example #2
0
    def list(self, request, *args, **kwargs):
        try:
            min_lat, max_lat, min_long, max_long = get_limits(request)
            start_date, end_date = get_start_and_end_dates(request)
        except ValueError as e:
            return Response({"status": str(e)}, status=status.HTTP_400_BAD_REQUEST)
        else:
            # add 1 minute to end_date because seconds were truncated from request
            end_date = end_date + timezone.timedelta(minutes=1)

            queryset = self.get_queryset().filter(coordinates__latitude__range=(min_lat, max_lat))
            queryset = queryset.filter(coordinates__longitude__range=(min_long, max_long))
            queryset = queryset.filter(created_on__range=(start_date, end_date))
            serializer = ReportSerializer(queryset, many=True)
            return Response(serializer.data)
Example #3
0
 def list(self, request, *args, **kwargs):
     queryset = self.get_queryset().filter(
         report__created_on__range=get_start_and_end_dates(request))
     serializer = ThreatSerializer(queryset, many=True)
     return Response(serializer.data)