From 370df82259196ce2aa90c258c449a7fbe06d0c34 Mon Sep 17 00:00:00 2001 From: Bartosz Karwacki Date: Sun, 23 Jan 2022 19:03:55 +0100 Subject: [PATCH] Settings from backend --- backend/cars/fuzzy_logic.py | 2 +- backend/cars/views.py | 12 ++++++++- frontend/src/components/Settings.vue | 38 ++++++++++++++++++---------- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/backend/cars/fuzzy_logic.py b/backend/cars/fuzzy_logic.py index f9ee3c1..1875010 100644 --- a/backend/cars/fuzzy_logic.py +++ b/backend/cars/fuzzy_logic.py @@ -77,7 +77,7 @@ def get_fuzzy_response(request_params, objects_list): car.combustion, ) ) - if min(comparator) > settings.COMPARATOR: + if comparator and min(comparator) > settings.COMPARATOR: end_object_list.append(car) return end_object_list diff --git a/backend/cars/views.py b/backend/cars/views.py index e9c5ff0..d84c540 100644 --- a/backend/cars/views.py +++ b/backend/cars/views.py @@ -1,7 +1,7 @@ -import re from rest_framework import generics from rest_framework.views import APIView from rest_framework.response import Response +from django.conf import settings from .fuzzy_logic import get_fuzzy_response from .models import Car from .serializers import CarSerializer @@ -23,3 +23,13 @@ class SettingsAPIView(APIView): def post(self, request, *args, **kwargs): set_settings_values(request.data) 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, + + }) \ No newline at end of file diff --git a/frontend/src/components/Settings.vue b/frontend/src/components/Settings.vue index b457c14..db6c877 100644 --- a/frontend/src/components/Settings.vue +++ b/frontend/src/components/Settings.vue @@ -13,7 +13,7 @@