Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
campaign
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
piphone
campaign
Commits
3f60b63e
Commit
3f60b63e
authored
Nov 22, 2014
by
Aymeric Barantal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter feedback categories based on campaign related organization
parent
9aa06bbc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
picampaign/campaign/models.py
picampaign/campaign/models.py
+1
-1
picampaign/organization/views.py
picampaign/organization/views.py
+4
-4
No files found.
picampaign/campaign/models.py
View file @
3f60b63e
...
...
@@ -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
,
...
...
picampaign/organization/views.py
View file @
3f60b63e
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
(
organization_id
=
orga
.
id
)
serializer
=
self
.
serializer_class
(
categories
,
many
=
True
)
return
Response
(
serializer
.
data
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment