mirror of
https://github.com/Reckless-Satoshi/robosats.git
synced 2024-08-17 07:40:38 +03:00
Fix admin panel avatars and avatar static removal at robot deletion
This commit is contained in:
parent
d77b8404c6
commit
fb5ef28b5d
@ -227,7 +227,7 @@ class Profile(models.Model):
|
||||
orders_disputes_started = models.CharField(max_length=999, null=True, default=None, validators=[validate_comma_separated_integer_list], blank=True) # Will only store ID of orders
|
||||
|
||||
# RoboHash
|
||||
avatar = models.ImageField(default=(settings.STATIC_ROOT+"unknown_avatar.png"), verbose_name='Avatar', blank=True)
|
||||
avatar = models.ImageField(default=("static/assets/avatars/"+"unknown_avatar.png"), verbose_name='Avatar', blank=True)
|
||||
|
||||
# Penalty expiration (only used then taking/cancelling repeatedly orders in the book before comitting bond)
|
||||
penalty_expiration = models.DateTimeField(null=True,default=None, blank=True)
|
||||
@ -247,7 +247,7 @@ class Profile(models.Model):
|
||||
@receiver(pre_delete, sender=User)
|
||||
def del_avatar_from_disk(sender, instance, **kwargs):
|
||||
try:
|
||||
avatar_file=Path(settings.AVATAR_ROOT + instance.profile.avatar.url)
|
||||
avatar_file=Path(settings.AVATAR_ROOT + instance.profile.avatar.url.split('/')[-1])
|
||||
avatar_file.unlink()
|
||||
except:
|
||||
pass
|
||||
|
@ -415,7 +415,7 @@ class UserView(APIView):
|
||||
if len(User.objects.filter(username=nickname)) == 0:
|
||||
User.objects.create_user(username=nickname, password=token, is_staff=False)
|
||||
user = authenticate(request, username=nickname, password=token)
|
||||
user.profile.avatar = nickname + '.png'
|
||||
user.profile.avatar = "static/assets/avatars/" + nickname + '.png'
|
||||
login(request, user)
|
||||
return Response(context, status=status.HTTP_201_CREATED)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
django==3.2.11
|
||||
django==3.2.12
|
||||
django-admin-relation-links==0.2.5
|
||||
django-celery-beat==2.2.1
|
||||
django-celery-results==2.2.0
|
||||
|
Loading…
Reference in New Issue
Block a user