Commit d3c33e90 authored by Aymeric Barantal's avatar Aymeric Barantal
Browse files

add POST for feedback, not proper code but work a minima

parent bf440a26
from import Feedback
from rest_framework import serializers
class FeedbackSerializer(serializers.ModelSerializer):
class Meta:
model = Feedback
fields = ('comment', 'callee')
from django.shortcuts import render
from rest_framework import viewsets
from rest_framework.response import Response
# Create your views here.
from import FeedbackSerializer
from import Feedback, FeedbackCategory
from picampaign.campaign.models import CampaignContact
class FeedbackViewSet(viewsets.ViewSet):
queryset = Feedback.objects.all()
serializer_class = FeedbackSerializer
def create(self, request, campaign_pk=None):
serializer = FeedbackSerializer(request.DATA)
callee = CampaignContact.objects.get(id=request.DATA['callee'])
category = FeedbackCategory.objects.get(id=request.DATA['category'])['callee'] = callee['category'] = category
feedback = Feedback(**
return Response(
......@@ -4,6 +4,7 @@ from rest_framework_nested import routers
from picampaign.campaign.views import (CampaignViewSet, CampaignContactViewSet,
from import FeedbackViewSet
router = routers.SimpleRouter()
router.register(r'campaigns', CampaignViewSet)
......@@ -12,6 +13,7 @@ campaign_router = routers.NestedSimpleRouter(router, r'campaigns',
campaign_router.register(r'contacts', CampaignContactViewSet)
campaign_router.register(r'arguments', ArgumentaryViewSet)
campaign_router.register(r'feedbacks', FeedbackViewSet)
urlpatterns = patterns('',
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment