From: Guillaume Pellerin Date: Tue, 15 Oct 2013 07:47:01 +0000 (+0200) Subject: fix item title X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=fa4413c5da26085fb69e3f23936d2b9b703f7279;p=telemeta.git fix item title --- diff --git a/telemeta/management/commands/telemeta-import-items.py b/telemeta/management/commands/telemeta-import-items.py index 9ab3c4b5..3d619556 100644 --- a/telemeta/management/commands/telemeta-import-items.py +++ b/telemeta/management/commands/telemeta-import-items.py @@ -28,9 +28,11 @@ class Command(BaseCommand): for root, dirs, files in os.walk(media_dir): for filename in files: path = root + os.sep + filename - items = MediaItem.objects.filter(code=filename) + filename_pre, ext = os.path.splitext(filename) + items = MediaItem.objects.filter(code=filename_pre) if not items: - item = MediaItem(collection=collection, code=filename) + item = MediaItem(collection=collection, code=filename_pre) + item.title = filename_pre f = open(path, 'r') file_content = ContentFile(f.read()) item.file.save(filename, file_content) @@ -38,4 +40,4 @@ class Command(BaseCommand): item.save() print 'item created: ' + item.code else: - print 'item already exists: ' + item.code + print 'item already exists: ' + items[0].code