mirror of
https://github.com/RoboSats/robosats.git
synced 2025-02-07 05:49:04 +00:00
Unlink avatars from prod static
This commit is contained in:
parent
d257848940
commit
04c9466c3e
@ -6,6 +6,7 @@ from django.template.defaultfilters import truncatechars
|
|||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.html import mark_safe
|
from django.utils.html import mark_safe
|
||||||
import uuid
|
import uuid
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from decouple import config
|
from decouple import config
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -209,7 +210,6 @@ def delete_lnpayment_at_order_deletion(sender, instance, **kwargs):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class Profile(models.Model):
|
class Profile(models.Model):
|
||||||
|
|
||||||
user = models.OneToOneField(User,on_delete=models.CASCADE)
|
user = models.OneToOneField(User,on_delete=models.CASCADE)
|
||||||
|
|
||||||
# Total trades
|
# Total trades
|
||||||
@ -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
|
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
|
# RoboHash
|
||||||
avatar = models.ImageField(default="static/assets/misc/unknown_avatar.png", verbose_name='Avatar', blank=True)
|
avatar = models.ImageField(default=(settings.STATIC_ROOT+"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 (only used then taking/cancelling repeatedly orders in the book before comitting bond)
|
||||||
penalty_expiration = models.DateTimeField(null=True,default=None, blank=True)
|
penalty_expiration = models.DateTimeField(null=True,default=None, blank=True)
|
||||||
@ -247,7 +247,7 @@ class Profile(models.Model):
|
|||||||
@receiver(pre_delete, sender=User)
|
@receiver(pre_delete, sender=User)
|
||||||
def del_avatar_from_disk(sender, instance, **kwargs):
|
def del_avatar_from_disk(sender, instance, **kwargs):
|
||||||
try:
|
try:
|
||||||
avatar_file=Path('frontend/' + instance.profile.avatar.url)
|
avatar_file=Path(settings.AVATAR_ROOT + instance.profile.avatar.url)
|
||||||
avatar_file.unlink()
|
avatar_file.unlink()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -258,7 +258,7 @@ class Profile(models.Model):
|
|||||||
# to display avatars in admin panel
|
# to display avatars in admin panel
|
||||||
def get_avatar(self):
|
def get_avatar(self):
|
||||||
if not self.avatar:
|
if not self.avatar:
|
||||||
return 'static/assets/misc/unknown_avatar.png'
|
return settings.STATIC_ROOT + 'unknown_avatar.png'
|
||||||
return self.avatar.url
|
return self.avatar.url
|
||||||
|
|
||||||
# method to create a fake table field in read only mode
|
# method to create a fake table field in read only mode
|
||||||
|
@ -23,6 +23,7 @@ import hashlib
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.conf import settings
|
||||||
from decouple import config
|
from decouple import config
|
||||||
|
|
||||||
EXP_MAKER_BOND_INVOICE = int(config('EXP_MAKER_BOND_INVOICE'))
|
EXP_MAKER_BOND_INVOICE = int(config('EXP_MAKER_BOND_INVOICE'))
|
||||||
@ -30,10 +31,7 @@ FEE = float(config('FEE'))
|
|||||||
RETRY_TIME = int(config('RETRY_TIME'))
|
RETRY_TIME = int(config('RETRY_TIME'))
|
||||||
|
|
||||||
|
|
||||||
avatar_path = Path('/usr/src/static/assets/avatars')
|
avatar_path = Path(settings.AVATAR_ROOT)
|
||||||
if os.environ.get('DEVELOPMENT'):
|
|
||||||
avatar_path = Path('frontend/static/assets/avatars')
|
|
||||||
|
|
||||||
avatar_path.mkdir(parents=True, exist_ok=True)
|
avatar_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
@ -417,7 +415,7 @@ class UserView(APIView):
|
|||||||
if len(User.objects.filter(username=nickname)) == 0:
|
if len(User.objects.filter(username=nickname)) == 0:
|
||||||
User.objects.create_user(username=nickname, password=token, is_staff=False)
|
User.objects.create_user(username=nickname, password=token, is_staff=False)
|
||||||
user = authenticate(request, username=nickname, password=token)
|
user = authenticate(request, username=nickname, password=token)
|
||||||
user.profile.avatar = str(image_path)[9:] # removes frontend/ from url (ugly, to be fixed)
|
user.profile.avatar = nickname + '.png'
|
||||||
login(request, user)
|
login(request, user)
|
||||||
return Response(context, status=status.HTTP_201_CREATED)
|
return Response(context, status=status.HTTP_201_CREATED)
|
||||||
|
|
||||||
|
@ -93,13 +93,13 @@ export default class BottomBar extends Component {
|
|||||||
<ListItemIcon><DnsIcon/></ListItemIcon>
|
<ListItemIcon><DnsIcon/></ListItemIcon>
|
||||||
{this.state.network == 'testnet'?
|
{this.state.network == 'testnet'?
|
||||||
<ListItemText secondary={this.state.node_alias}>
|
<ListItemText secondary={this.state.node_alias}>
|
||||||
<a href={"https://1ml.com/testnet/node/"
|
<a target="_blank" href={"https://1ml.com/testnet/node/"
|
||||||
+ this.state.node_id}>{this.state.node_id.slice(0, 12)+"... (1ML)"}
|
+ this.state.node_id}>{this.state.node_id.slice(0, 12)+"... (1ML)"}
|
||||||
</a>
|
</a>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
:
|
:
|
||||||
<ListItemText secondary={this.state.node_alias}>
|
<ListItemText secondary={this.state.node_alias}>
|
||||||
<a href={"https://1ml.com/node/"
|
<a target="_blank" href={"https://1ml.com/node/"
|
||||||
+ this.state.node_id}>{this.state.node_id.slice(0, 12)+"... (1ML)"}
|
+ this.state.node_id}>{this.state.node_id.slice(0, 12)+"... (1ML)"}
|
||||||
</a>
|
</a>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
@ -110,7 +110,7 @@ export default class BottomBar extends Component {
|
|||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemIcon><WebIcon/></ListItemIcon>
|
<ListItemIcon><WebIcon/></ListItemIcon>
|
||||||
<ListItemText secondary={this.state.alternative_name}>
|
<ListItemText secondary={this.state.alternative_name}>
|
||||||
<a href={"https://"+this.alternative_site}>{this.state.alternative_site.slice(0, 12)+"...onion"}
|
<a target="_blank" href={"https://"+this.alternative_site}>{this.state.alternative_site.slice(0, 12)+"...onion"}
|
||||||
</a>
|
</a>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
@ -119,7 +119,7 @@ export default class BottomBar extends Component {
|
|||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemIcon><GitHubIcon/></ListItemIcon>
|
<ListItemIcon><GitHubIcon/></ListItemIcon>
|
||||||
<ListItemText secondary="Currently running commit hash">
|
<ListItemText secondary="Currently running commit hash">
|
||||||
<a href={"https://github.com/Reckless-Satoshi/robosats/tree/"
|
<a target="_blank" href={"https://github.com/Reckless-Satoshi/robosats/tree/"
|
||||||
+ this.state.robosats_running_commit_hash}>{this.state.robosats_running_commit_hash.slice(0, 12)+"..."}
|
+ this.state.robosats_running_commit_hash}>{this.state.robosats_running_commit_hash.slice(0, 12)+"..."}
|
||||||
</a>
|
</a>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
|
File diff suppressed because one or more lines are too long
@ -26,14 +26,15 @@ STATIC_URL = '/static/'
|
|||||||
SECRET_KEY = config('SECRET_KEY')
|
SECRET_KEY = config('SECRET_KEY')
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = 'static/'
|
||||||
STATIC_ROOT ='/usr/src/static/'
|
STATIC_ROOT ='/usr/src/static/'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
if os.environ.get('DEVELOPMENT'):
|
if os.environ.get('DEVELOPMENT'):
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
STATIC_URL = '/static/'
|
STATIC_ROOT = 'frontend/static/'
|
||||||
STATIC_ROOT = os.path.join(BASE_DIR, 'frontend/static/')
|
|
||||||
|
AVATAR_ROOT = STATIC_ROOT + 'assets/avatars/'
|
||||||
|
|
||||||
ALLOWED_HOSTS = [config('HOST_NAME'),'127.0.0.1']
|
ALLOWED_HOSTS = [config('HOST_NAME'),'127.0.0.1']
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user