From ad5a242f8db3f1e53ae851d09621ca8b1a0abb43 Mon Sep 17 00:00:00 2001 From: ticvac Date: Tue, 12 Nov 2024 20:31:08 +0100 Subject: [PATCH] upravy generate filename --- soustredeni/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/soustredeni/models.py b/soustredeni/models.py index e5d11ae9..d18d8da6 100644 --- a/soustredeni/models.py +++ b/soustredeni/models.py @@ -18,8 +18,11 @@ from django.utils import timezone def generate_filename_kontaktnicek(self, filename): # generate random string length = 32 - file_type = filename.split('.')[-1] - fname = "kontaktnicky/" + timezone.now().strftime('%Y-%m-%d-%H_%M') + "" + if len(filename.split('.')) == 1: + 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 += '.' + file_type return os.path.join(settings.SOUSTREDENI_KONTAKTNICKY_DIR, fname)