Skip to content

Commit

Permalink
fix(avater update): fixes profile image uploading to the application. (
Browse files Browse the repository at this point in the history
…#43)

- fixes update profile avatar url

 [Delivers #163296321]
  • Loading branch information
verenceLola authored and dotNesh committed Jan 17, 2019
1 parent 896022e commit cee888b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions authors/apps/profiles/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ class ProfileSerializer(serializers.ModelSerializer):
username = serializers.CharField(source='user.username')
last_login = serializers.CharField(source='user.last_login', allow_blank=True)
country = serializers.CharField(allow_blank=True, required=False)
website = serializers.CharField(allow_blank=True, required=False)
website = serializers.URLField(allow_blank=True, required=False)
phone = serializers.CharField(allow_blank=True, required=False)
bio = serializers.CharField(allow_blank=True, required=False)
created_at = serializers.DateTimeField()
avatar = serializers.SerializerMethodField()
avatar = serializers.URLField(allow_blank=True, required=False)
notifications_enabled = serializers.BooleanField()

phone = serializers.RegexField(
regex="^[0-9]",
max_length=10,
max_length=12,
min_length=10,
error_messages={
"invalid": "This field should only contain numbers.",
"max_length": "Phone Number cannot be longer than 10 characters",
"min_length": "Phone Number cannot be less than 10 characters"
}
"min_length": "Phone Number cannot be less than 12 characters"
},
allow_blank=True
)

class Meta:
Expand All @@ -39,8 +40,3 @@ class Meta:
'avatar',
'notifications_enabled',
)

def get_avatar(self, object):
"""return the user avatar, or default avatar if non is set"""
if object.avatar:
return object.avatar
2 changes: 1 addition & 1 deletion authors/apps/profiles/tests/test_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_update_profile(self):
HTTP_AUTHORIZATION='Token '+token,
data={
'user':{
'website':'newwebsite.com',
'website':'http://newwebsite.com',
'phone':'0721201048'
}
}
Expand Down

0 comments on commit cee888b

Please sign in to comment.