Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
piphone
campaign
Commits
82b2f88b
Commit
82b2f88b
authored
Nov 23, 2014
by
Aymeric Barantal
Browse files
add photo url on contacts API
parent
ddae0222
Changes
2
Hide whitespace changes
Inline
Side-by-side
picampaign/campaign/serializers.py
View file @
82b2f88b
...
...
@@ -25,8 +25,9 @@ class CampaignContactSerializer(serializers.HyperlinkedModelSerializer):
phone
=
serializers
.
Field
(
source
=
'contact.phone'
)
groups
=
GroupSerializer
(
many
=
True
,
source
=
'contact.groups'
)
contact_id
=
serializers
.
Field
(
source
=
'contact.id'
)
photo
=
serializers
.
Field
(
source
=
'contact.get_photo_url'
)
class
Meta
:
model
=
CampaignContact
fields
=
(
'id'
,
'weight'
,
'contact_id'
,
'first_name'
,
'last_name'
,
'phone'
,
'groups'
)
'first_name'
,
'last_name'
,
'phone'
,
'groups'
,
'photo'
)
picampaign/contact/models.py
View file @
82b2f88b
...
...
@@ -15,3 +15,8 @@ class Contact(models.Model):
def
__unicode__
(
self
):
return
_
(
'%(firstname) %(lastname)'
)
%
{
'firstname'
:
self
.
first_name
,
'lastname'
:
self
.
last_name
}
def
get_photo_url
(
self
):
if
self
.
photo
:
return
self
.
photo
.
url
return
u
''
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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