26 lines
821 B
Python
26 lines
821 B
Python
import re
|
|
from rest_framework import generics
|
|
from rest_framework.views import APIView
|
|
from rest_framework.response import Response
|
|
from .fuzzy_logic import get_fuzzy_response
|
|
from .models import Car
|
|
from .serializers import CarSerializer
|
|
from .utils import map_query_params, set_settings_values
|
|
|
|
|
|
class CarList(generics.ListAPIView):
|
|
queryset = Car.objects.all()
|
|
serializer_class = CarSerializer
|
|
|
|
def list(self, request):
|
|
values = map_query_params(request.query_params)
|
|
response = get_fuzzy_response(values, self.get_queryset())
|
|
serializer = CarSerializer(response, many=True)
|
|
return Response(serializer.data)
|
|
|
|
|
|
class SettingsAPIView(APIView):
|
|
def post(self, request, *args, **kwargs):
|
|
set_settings_values(request.data)
|
|
return Response("Settings changed")
|