Commit 27371eea authored by Aymeric Barantal's avatar Aymeric Barantal
Browse files

add /campaigns/<id>/categories API, need rework

parent d3c33e90
from picampaign.organization.models import FeedbackCategory
from rest_framework import serializers
class CategorySerializer(serializers.ModelSerializer):
class Meta:
model = FeedbackCategory
fields = ('id', 'name')
from django.shortcuts import render
from rest_framework import viewsets
from rest_framework.response import Response
# Create your views here.
from picampaign.organization.models import FeedbackCategory
from picampaign.organization.serializers import CategorySerializer
class CategoryViewSet(viewsets.ViewSet):
queryset = FeedbackCategory.objects.all()
serializer_class = CategorySerializer
def list(self, request, campaign_pk=None):
# XXX need an organization in request to filter upon
categories = self.queryset.all()
serializer = self.serializer_class(categories, many=True)
return Response(
......@@ -5,6 +5,7 @@ from rest_framework_nested import routers
from picampaign.campaign.views import (CampaignViewSet, CampaignContactViewSet,
from import FeedbackViewSet
from picampaign.organization.views import CategoryViewSet
router = routers.SimpleRouter()
router.register(r'campaigns', CampaignViewSet)
......@@ -13,6 +14,7 @@ campaign_router = routers.NestedSimpleRouter(router, r'campaigns',
campaign_router.register(r'contacts', CampaignContactViewSet)
campaign_router.register(r'arguments', ArgumentaryViewSet)
campaign_router.register(r'categories', CategoryViewSet)
campaign_router.register(r'feedbacks', FeedbackViewSet)
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