Skip to content

Commit

Permalink
Catch on valerror for avatar url and default to proxied uri
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeacom committed Oct 14, 2018
1 parent 25846b9 commit 4dc217a
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions app/avatar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,30 @@ def get_avatar_url(self, use_svg=True):
use_svg (bool): Whether or not to use SVG format.
"""
if not use_svg:
if self.use_github_avatar and self.png:
return self.png.url
if self.use_github_avatar and not self.png:
return self.pull_github_avatar()
if not self.use_github_avatar and self.custom_avatar_png:
return self.custom_avatar_png.url
if not self.use_github_avatar and not self.custom_avatar_png:
self.convert_custom_svg(force_save=True)
return self.custom_avatar_png.url
if self.use_github_avatar and self.github_svg:
return self.github_svg.url
if self.use_github_avatar and not self.github_svg:
if self.png:
self.convert_github_png(force_save=True)
try:
if not use_svg:
if self.use_github_avatar and self.png:
return self.png.url
if self.use_github_avatar and not self.png:
return self.pull_github_avatar()
if not self.use_github_avatar and self.custom_avatar_png:
return self.custom_avatar_png.url
if not self.use_github_avatar and not self.custom_avatar_png:
self.convert_custom_svg(force_save=True)
return self.custom_avatar_png.url
if self.use_github_avatar and self.github_svg:
return self.github_svg.url
if not self.use_github_avatar and self.svg:
return self.svg.url
if not self.use_github_avatar and not self.svg:
self.create_from_config()
return self.svg.url
if self.use_github_avatar and not self.github_svg:
if self.png:
self.convert_github_png(force_save=True)
return self.github_svg.url
if not self.use_github_avatar and self.svg:
return self.svg.url
if not self.use_github_avatar and not self.svg:
self.create_from_config()
return self.svg.url
except ValueError:
pass

try:
handle = self.profile_set.last().handle
Expand Down

0 comments on commit 4dc217a

Please sign in to comment.