This commit is contained in:
Bartosz Karwacki 2022-01-23 19:07:02 +01:00
parent 41305d18cd
commit 52649a0beb
6 changed files with 20 additions and 15 deletions

View File

@ -14,6 +14,6 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import include, path
urlpatterns = [path("admin/", admin.site.urls), path("", include("cars.urls"))]

View File

@ -1,4 +1,5 @@
from django.contrib import admin
from .models import Car
admin.site.register(Car)

View File

@ -1,7 +1,7 @@
import numpy as np
import skfuzzy as fuzz
from skfuzzy import control as ctrl
from django.conf import settings
from skfuzzy import control as ctrl
def get_fuzzy_response(request_params, objects_list):
@ -79,5 +79,5 @@ def get_fuzzy_response(request_params, objects_list):
)
if comparator and min(comparator) > settings.COMPARATOR:
end_object_list.append(car)
return end_object_list

View File

@ -1,4 +1,5 @@
from rest_framework import serializers
from .models import Car

View File

@ -1,4 +1,5 @@
from django.urls import path, include
from django.urls import include, path
from .views import CarList, SettingsAPIView
# The API URLs are now determined automatically by the router.

View File

@ -1,7 +1,8 @@
from rest_framework import generics
from rest_framework.views import APIView
from rest_framework.response import Response
from django.conf import settings
from rest_framework import generics
from rest_framework.response import Response
from rest_framework.views import APIView
from .fuzzy_logic import get_fuzzy_response
from .models import Car
from .serializers import CarSerializer
@ -25,11 +26,12 @@ class SettingsAPIView(APIView):
return Response("Settings changed")
def get(self, request, *args, **kwargs):
return Response({
'production_year':settings.PRODUCTION_YEAR,
'mileage':settings.MILEAGE,
'engine_capacity':settings.ENGINE_CAPACITY,
'combustion':settings.COMBUSTION,
'comparator':settings.COMPARATOR,
})
return Response(
{
"production_year": settings.PRODUCTION_YEAR,
"mileage": settings.MILEAGE,
"engine_capacity": settings.ENGINE_CAPACITY,
"combustion": settings.COMBUSTION,
"comparator": settings.COMPARATOR,
}
)