Skip to content

Commit

Permalink
Added picture_url property to return safe url strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Fer-Bar committed May 23, 2024
1 parent 0c6a66f commit f3cc2d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ class Person(models.Model):
help_text=_("Max size allowed: 20Mbs"),
)

@property
def picture_url(self):
"""
Return self.picture.url if self.picture is not None,
'url' exist and has a value, else, return None.
"""
if self.picture and hasattr(self.picture, "url"):
return self.picture.url

def create_user(self):
if self.user_id is not None:
return
Expand Down

0 comments on commit f3cc2d1

Please sign in to comment.