Skip to content

Commit

Permalink
remove leftover of avatar generator (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryfletcher21 authored Jul 7, 2024
1 parent 35d37e6 commit 6f4989c
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions api/models/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,5 @@ def create_user_robot(sender, instance, created, **kwargs):
def save_user_robot(sender, instance, **kwargs):
instance.robot.save()

@receiver(pre_delete, sender=User)
def del_avatar_from_disk(sender, instance, **kwargs):
try:
avatar_file = Path(
settings.AVATAR_ROOT + instance.robot.avatar.url.split("/")[-1]
)
avatar_file.unlink()
except Exception:
pass

def __str__(self):
return self.user.username

# to display avatars in admin panel
def get_avatar(self):
if not self.avatar:
return settings.STATIC_ROOT + "unknown_avatar.png"
return self.avatar.url

# method to create a fake table field in read only mode
def avatar_tag(self):
return mark_safe('<img src="%s" width="50" height="50" />' % self.get_avatar())

0 comments on commit 6f4989c

Please sign in to comment.