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
2444d374
Commit
2444d374
authored
Nov 22, 2014
by
Aymeric Barantal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flatten output for campaigns/<id>/contacts
parent
27371eea
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
picampaign/campaign/models.py
picampaign/campaign/models.py
+3
-0
picampaign/campaign/serializers.py
picampaign/campaign/serializers.py
+6
-10
picampaign/organization/models.py
picampaign/organization/models.py
+2
-1
No files found.
picampaign/campaign/models.py
View file @
2444d374
...
...
@@ -56,3 +56,6 @@ class CampaignContact(models.Model):
def
__unicode__
(
self
):
return
'Contact %s on %s'
%
(
self
.
contact
,
self
.
campaign
.
title
)
def
all_groups
(
self
):
return
[
x
.
name
for
x
in
self
.
contact
.
groups
.
all
()]
picampaign/campaign/serializers.py
View file @
2444d374
from
picampaign.campaign.models
import
(
Campaign
,
CampaignContact
,
Contact
,
from
picampaign.campaign.models
import
(
Campaign
,
CampaignContact
,
Argumentary
)
from
rest_framework
import
serializers
class
ContactSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
Contact
fields
=
(
'id'
,
'first_name'
,
'last_name'
,
'phone'
)
class
ArgumentarySerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
...
...
@@ -26,8 +19,11 @@ class CampaignSerializer(serializers.HyperlinkedModelSerializer):
class
CampaignContactSerializer
(
serializers
.
HyperlinkedModelSerializer
):
contact
=
ContactSerializer
(
many
=
False
)
first_name
=
serializers
.
Field
(
source
=
'contact.first_name'
)
last_name
=
serializers
.
Field
(
source
=
'contact.last_name'
)
phone
=
serializers
.
Field
(
source
=
'contact.phone'
)
groups
=
serializers
.
Field
(
source
=
'all_groups'
)
class
Meta
:
model
=
CampaignContact
fields
=
(
'id'
,
'weight'
,
'
contact
'
)
fields
=
(
'id'
,
'weight'
,
'
first_name'
,
'last_name'
,
'phone'
,
'groups
'
)
picampaign/organization/models.py
View file @
2444d374
...
...
@@ -20,7 +20,8 @@ class Group(models.Model):
name
=
models
.
CharField
(
max_length
=
64
)
type
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
)
media
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
)
contacts
=
models
.
ManyToManyField
(
Contact
,
null
=
True
,
blank
=
True
)
contacts
=
models
.
ManyToManyField
(
Contact
,
null
=
True
,
blank
=
True
,
related_name
=
'groups'
)
def
__unicode__
(
self
):
return
self
.
name
...
...
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