Commit 82b2f88b authored by Aymeric Barantal's avatar Aymeric Barantal

add photo url on contacts API

parent ddae0222
......@@ -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')
......@@ -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''
Markdown is supported
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