From 0dff3d43dbe96b92e41840d049c01f20a0a27d98 Mon Sep 17 00:00:00 2001 From: John Giannelos Date: Tue, 20 Oct 2015 12:30:55 +0300 Subject: [PATCH] [Fix bug 1216291] Fix `photo` definition in UserProfileDetailedSerializer. --- mozillians/users/api/v2.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mozillians/users/api/v2.py b/mozillians/users/api/v2.py index 257c97b72..680134bcd 100644 --- a/mozillians/users/api/v2.py +++ b/mozillians/users/api/v2.py @@ -63,6 +63,7 @@ class Meta: class UserProfileDetailedSerializer(serializers.HyperlinkedModelSerializer): username = serializers.Field(source='user.username') email = serializers.Field(source='email') + photo = serializers.SerializerMethodField('get_photo') alternate_emails = AlternateEmailSerializer(many=True, source='alternate_emails') country = serializers.SerializerMethodField('get_country') region = serializers.SerializerMethodField('get_region') @@ -120,15 +121,18 @@ def transform_bio(self, obj, value): 'privacy': obj.get_privacy_bio_display(), } - def transform_photo(self, obj, value): + def get_photo(self, obj): return { 'value': obj.get_photo_url('300x300'), '150x150': obj.get_photo_url('150x150'), '300x300': obj.get_photo_url('300x300'), '500x500': obj.get_photo_url('500x500'), - 'privacy': obj.get_privacy_photo_display(), } + def transform_photo(self, obj, value): + field_privacy = {'privacy': obj.get_privacy_photo_display()} + return value.update(field_privacy) + def transform_tshirt(self, obj, value): return { 'value': obj.tshirt,