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
28bcab73
Commit
28bcab73
authored
Feb 11, 2019
by
Okhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All phones if no filter + twitter and photo ad emails
parent
fa9c2b7d
Pipeline
#2433
passed with stages
in 2 minutes and 29 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
picampaign/campaign/serializers.py
picampaign/campaign/serializers.py
+5
-3
picampaign/campaign/test_serializers.py
picampaign/campaign/test_serializers.py
+1
-1
picampaign/campaign/test_views.py
picampaign/campaign/test_views.py
+1
-1
No files found.
picampaign/campaign/serializers.py
View file @
28bcab73
...
...
@@ -31,13 +31,15 @@ class CampaignContactSerializer(serializers.HyperlinkedModelSerializer):
phone
=
PhoneSerializer
(
many
=
True
,
source
=
'contact.phones'
)
groups
=
GroupSerializer
(
many
=
True
,
source
=
'contact.groups'
)
contact_id
=
serializers
.
ReadOnlyField
(
source
=
'contact.id'
)
email
=
serializers
.
ReadOnlyField
(
source
=
'contact.email'
)
twitter
=
serializers
.
ReadOnlyField
(
source
=
'contact.twitter'
)
photo
=
serializers
.
ReadOnlyField
(
source
=
'contact.get_photo_url'
)
class
Meta
:
model
=
CampaignContact
fields
=
(
'id'
,
'weight'
,
'contact_id'
,
'full_name'
,
'first_name'
,
'last_name'
,
'phone'
,
'groups'
,
'photo'
)
'phone'
,
'groups'
,
'photo'
,
'email'
,
'twitter'
)
def
to_representation
(
self
,
instance
):
"""
...
...
@@ -49,8 +51,8 @@ class CampaignContactSerializer(serializers.HyperlinkedModelSerializer):
# We should have a filter parameter for the campaign
filter
=
campaign
.
phone_filter
if
filter
==
''
or
filter
is
None
:
# No filter, we
just return the first phone number
data
[
'phone'
]
=
data
[
'phone'
][
0
][
'phone'
]
# No filter, we
return all the numbers
data
[
'phone'
]
=
[
a
[
'phone'
]
for
a
in
data
[
'phone'
]
]
return
data
else
:
for
phone
in
data
[
'phone'
]:
...
...
picampaign/campaign/test_serializers.py
View file @
28bcab73
...
...
@@ -57,7 +57,7 @@ class CampaignContactSerializerTest(TestCase):
contact
=
contact
)
serializer
=
CampaignContactSerializer
(
campaigncontact
)
self
.
assertEqual
(
serializer
.
to_representation
(
campaigncontact
)[
'phone'
],
contact
.
phones
.
first
().
phone
)
self
.
assertEqual
(
serializer
.
to_representation
(
campaigncontact
)[
'phone'
],
[
phone
.
phone
for
phone
in
contact
.
phones
.
all
()]
)
# Let's add a phone filter
campaign
.
phone_filter
=
'98'
self
.
assertEqual
(
serializer
.
to_representation
(
campaigncontact
)[
'phone'
],
contact
.
phones
.
last
().
phone
)
picampaign/campaign/test_views.py
View file @
28bcab73
...
...
@@ -46,7 +46,7 @@ class ViewSetTest(TestCase):
client
=
APIClient
()
response
=
client
.
get
(
'/campaigns/%(cid)d/contacts/'
%
{
'cid'
:
self
.
campaign
.
id
},
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
content
,
b
'[{"id":1,"weight":0,"contact_id":1,"full_name":"Victor Hugo","first_name":"Victor","last_name":"Hugo","phone":
"0123456789","groups":[],"photo
":""}]'
)
self
.
assertEqual
(
response
.
content
,
b
'[{"id":1,"weight":0,"contact_id":1,"full_name":"Victor Hugo","first_name":"Victor","last_name":"Hugo","phone":
["0123456789"],"groups":[],"photo":"","twitter
":""}]'
)
def
test_campaign_argumentary_viewset
(
self
):
client
=
APIClient
()
...
...
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