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 266ac6c commit 28456cc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 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,19 @@ 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):
privacy_field = {'privacy': obj.get_privacy_photo_display()}
value.update(privacy_field)
return value

def transform_tshirt(self, obj, value):
return {
'value': obj.tshirt,
Expand Down

0 comments on commit 28456cc

Please sign in to comment.