Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
[Fix bug 1216291] Fix photo definition in UserProfileDetailedSerial…
Browse files Browse the repository at this point in the history
…izer.
  • Loading branch information
johngian committed Oct 20, 2015
1 parent c277905 commit 0dff3d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mozillians/users/api/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0dff3d4

Please sign in to comment.