Commit 3f60b63e authored by Aymeric Barantal's avatar Aymeric Barantal
Browse files

filter feedback categories based on campaign related organization

parent 9aa06bbc
......@@ -14,7 +14,7 @@ class Campaign(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=255)
description = models.CharField(max_length=512, blank=True)
organization = models.ForeignKey(Organization)
organization = models.ForeignKey(Organization, related_name='campaigns')
start_date = models.DateField()
end_date = models.DateField()
default_lang = models.CharField(max_length=5,
from rest_framework import viewsets
from rest_framework.response import Response
from picampaign.organization.models import FeedbackCategory
from picampaign.organization.models import FeedbackCategory, Organization
from picampaign.organization.serializers import CategorySerializer
......@@ -10,8 +10,8 @@ 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()
def list(self, request, campaign_pk):
orga = Organization.objects.filter(campaigns__id=campaign_pk)[0]
categories = self.queryset.filter(
serializer = self.serializer_class(categories, many=True)
return Response(
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