Skip to content

Commit

Permalink
Merge branch 'eureka_pub' of github.com:caumons/django-avatar into ca…
Browse files Browse the repository at this point in the history
…umons-eureka_pub
  • Loading branch information
johanneswilm committed Aug 10, 2022
2 parents b986082 + 5ad41df commit 5452d4e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions avatar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ def avatar_name(self, size):


def invalidate_avatar_cache(sender, instance, **kwargs):
invalidate_cache(instance.user)
if hasattr(instance, "user"):
invalidate_cache(instance.user)


def create_default_thumbnails(sender, instance, created=False, **kwargs):
Expand All @@ -199,9 +200,10 @@ def create_default_thumbnails(sender, instance, created=False, **kwargs):


def remove_avatar_images(instance=None, **kwargs):
for size in settings.AVATAR_AUTO_GENERATE_SIZES:
if instance.thumbnail_exists(size):
instance.avatar.storage.delete(instance.avatar_name(size))
if hasattr(instance, "user"):
for size in settings.AVATAR_AUTO_GENERATE_SIZES:
if instance.thumbnail_exists(size):
instance.avatar.storage.delete(instance.avatar_name(size))
if instance.avatar.storage.exists(instance.avatar.name):
instance.avatar.storage.delete(instance.avatar.name)

Expand Down

0 comments on commit 5452d4e

Please sign in to comment.