description_fuckery.

This commit is contained in:
Marcus Scholz 2020-12-25 13:19:34 +01:00
parent 3eaa186b66
commit 86cc7f23fe

View File

@ -65,27 +65,12 @@ class Explorer(models.Model):
def __str__(self):
return self.user.username
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
"""
Delete Explorer profile when User gets deleted.
Deletion on profile_pic update is not necessary, as it gets
simply overwritten.
"""
if created:
Explorer.objects.create(user=instance)
def auto_delete_file_on_delete(sender, instance, **kwargs):
"""
Deletes file (including thumbnails) from filesystem
when corresponding `profile_image` object is deleted.
"""
if instance.profile_image:
# Get and delete all files and thumbnails from instance
thumbmanager = get_thumbnailer(instance.profile_image)
thumbmanager.delete(save=False)
@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
instance.explorer.save()