upravy generate filename
This commit is contained in:
parent
6186914a7c
commit
ad5a242f8d
1 changed files with 5 additions and 2 deletions
|
@ -18,8 +18,11 @@ from django.utils import timezone
|
||||||
def generate_filename_kontaktnicek(self, filename):
|
def generate_filename_kontaktnicek(self, filename):
|
||||||
# generate random string
|
# generate random string
|
||||||
length = 32
|
length = 32
|
||||||
file_type = filename.split('.')[-1]
|
if len(filename.split('.')) == 1:
|
||||||
fname = "kontaktnicky/" + timezone.now().strftime('%Y-%m-%d-%H_%M') + ""
|
file_type = 'lol_neumíš_tam_dát_příponu'
|
||||||
|
else:
|
||||||
|
file_type = filename.split('.')[-1]
|
||||||
|
fname = timezone.now().strftime('%Y-%m-%d-%H_%M') + ""
|
||||||
fname += ''.join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(length))
|
fname += ''.join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(length))
|
||||||
fname += '.' + file_type
|
fname += '.' + file_type
|
||||||
return os.path.join(settings.SOUSTREDENI_KONTAKTNICKY_DIR, fname)
|
return os.path.join(settings.SOUSTREDENI_KONTAKTNICKY_DIR, fname)
|
||||||
|
|
Loading…
Reference in a new issue