def get_profile_picture(self, size=50):
"""Returns the url to the profile picture for the user.
TODO: This method needs major fixing. What's going on with that URL?
:param int size: The size of the image to pass, if the size can be
changed.
:returns: The URL of the image.
:rtype: str
"""
if self.image:
return self.image.url()
if not self.image_url:
return ('https://lh6.googleusercontent.com/-K9HZ5Z5vOU8/'
'AAAAAAAAAAI/AAAAAAAAAAA/yRoMtBSXoxQ/s48-c/photo.jpg')
if "googleusercontent.com" in self.image_url:
return self.image_url + str(size)
return self.image_url
Possible better approaches:
Store the default locally, instead of on googleusercontent.com
Our current approach (in
app/models/User.py
):Possible better approaches: