From 7f8d921953117ddf7bccf03100a3f61043ead111 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 18 Jul 2014 10:31:28 +0200 Subject: [PATCH] fix script rename --- teleforma/exam/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/teleforma/exam/models.py b/teleforma/exam/models.py index 816a63d0..669c7d7d 100644 --- a/teleforma/exam/models.py +++ b/teleforma/exam/models.py @@ -42,6 +42,7 @@ from django.db.models import Q, Max, Min from django.db.models.signals import post_save from django.conf import settings from django.utils.translation import ugettext, ugettext_lazy as _ +from django.template.defaultfilters import slugify from teleforma.models import * from django.template.loader import render_to_string @@ -278,10 +279,12 @@ class Script(BaseResource): def fix_filename(self): old = self.file.path old_list = old.split(os.sep) - path = old_list[:-2] - new = os.sep.join(path) + os.sep + unicode(self.uuid) + '.pdf' + path = old_list[:-1] + filename, ext = os.path.splitext(old_list[-1]) + new = os.sep.join(path) + os.sep + slugify(filename) + ext os.rename(old, new) self.file = new + self.save() def submit(self): self.date_submitted = datetime.datetime.now() -- 2.39.5