Fix upload paths for non-user related files
This commit is contained in:
parent
517e35a7d0
commit
08e65b2150
1 changed files with 6 additions and 1 deletions
|
@ -18,7 +18,12 @@ def profile_to_coords(profile):
|
|||
return name_to_coords("%s, %s, %s, %s" % (profile.street, profile.city, profile.zip, profile.country))
|
||||
|
||||
def upload_path(instance, filename):
|
||||
return f'userfiles/{instance.user.id}/{uuid.uuid4()}/{filename}'
|
||||
try:
|
||||
user_id = instance.user.id
|
||||
except:
|
||||
user_id = "global"
|
||||
|
||||
return f'userfiles/{user_id}/{uuid.uuid4()}/{filename}'
|
||||
|
||||
def generate_token(length=6, characters=string.digits):
|
||||
return "".join([SystemRandom().choice(characters) for _ in range(length)])
|
||||
|
|
Loading…
Reference in a new issue