from django.core.exceptions import ObjectDoesNotExist

from rest_framework.views import APIView
from rest_framework.response import Response
from .models import Form
from .serializers import FormSerializer

class FormsView(APIView):

    queryset = Form.objects.all()

    def get(self, request, format=None, **kwargs):
        if kwargs.get('form_id'):
            try:
                return Response(None)
            except ObjectDoesNotExist:
                return Response({"error": "could not find user"}    , status=400)
        else:
            return Response(None)

    def post(self, request, format=None, **kwargs):
        response = Response()
        serializer = FormSerializer(data=request.data)

        if serializer.is_valid():
            serializer.save()
            response.status_code = 201
            response.data = serializer.validated_data
        else:
            response.status_code = 400
        return response

    def delete(self, request, format=None, **kwargs):
        response = Response()
        if kwargs.get("form_id"):
            form = Form.objects.get(id=kwargs['form_id'])
            if form:
                form.delete()
                response.status_code = 204
            else:
                pass
        else:
            response.status_code = 400

        return response
@@ -549,37 +549,158 @@
         
-return Response(None)
+forms = Form.objects.all()%0A            forms_serialized = FormSerializer(forms, many=True)%0A            return Response(forms_serialized.data)%0A
 %0A%0A    de
@@ -767,32 +767,60 @@
 se = Response()%0A
+        print(request.data)%0A
         serializ

add correct method to read all forms of a company