backend/exhauster_analytics/analytics/api/views.py

26 lines
856 B
Python
Raw Permalink Normal View History

2023-02-18 23:51:02 +03:00
from rest_framework import generics
from rest_framework.response import Response
from exhauster_analytics.analytics.services import get_signal_values
from exhauster_analytics.analytics.api.serializers import (
ExgausterSerializer,
ExgausterSignalSerializer,
)
from exhauster_analytics.analytics.models import Exgauster
class ListExgauster(generics.ListAPIView):
serializer_class = ExgausterSerializer
queryset = Exgauster.objects.all()
permission_classes = []
class GetApproximatedExgausterSignals(generics.GenericAPIView):
serializer_class = ExgausterSignalSerializer
permission_classes = []
def post(self, request, *args, **kwargs):
serializer = ExgausterSignalSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
return Response(data=get_signal_values(**serializer.data))