views.py 704 Bytes
Newer Older
okhin's avatar
okhin committed
1 2 3
import json

from django.views.decorators.csrf import csrf_exempt
4 5
from rest_framework import viewsets
from rest_framework.response import Response
Aymeric Barantal's avatar
Aymeric Barantal committed
6

7 8
from picampaign.feedback.serializers import FeedbackSerializer
from picampaign.feedback.models import Feedback, FeedbackCategory
okhin's avatar
okhin committed
9
from picampaign.contact.models import Contact
10 11 12 13 14 15 16


class FeedbackViewSet(viewsets.ViewSet):

    queryset = Feedback.objects.all()
    serializer_class = FeedbackSerializer

okhin's avatar
okhin committed
17
    @csrf_exempt
18
    def create(self, request, campaign_pk=None):
okhin's avatar
okhin committed
19
        serializer = FeedbackSerializer(data=request.data)
20
        serializer.is_valid()
okhin's avatar
okhin committed
21
        feedback = serializer.create(serializer.validated_data)
22
        return Response(feedback.id)