]> git.parisson.com Git - teleforma.git/commitdiff
cleanup seminar media during import
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 31 Dec 2015 16:59:11 +0000 (17:59 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 31 Dec 2015 16:59:11 +0000 (17:59 +0100)
teleforma/management/commands/teleforma-import-seminar-media-update.py

index 766e135d35aaec48dbf86e8b65047ddaaffeac9f..1624927f97188f025d708098639a324aa690fe2c 100644 (file)
@@ -166,10 +166,10 @@ class Command(BaseCommand):
                         seminar.status = 1
                         seminar.save()
 
-                    for media in seminar.medias.all():
-                    #     seminar.medias.remove(media)
-                    #     media.item.delete()
-                    #     media.delete()
+                    for media in seminar.medias.all():
+                         seminar.medias.remove(media)
+                         media.item.delete()
+                         media.delete()
 
                     collections = MediaCollection.objects.filter(code=collection_id)
                     if not collections:
@@ -233,6 +233,8 @@ class Command(BaseCommand):
                             if os.path.exists(dir):
                                 r_dir = os.sep.join(dir.split(os.sep)[-7:])
                                 files = os.listdir(dir)
+                                if files and seminar.media_preview:
+                                    seminar.media_preview.delete()
                                 code = item.code + '_preview'
                                 title = item.title + ' (preview)'
                                 item = self.get_item(collection, code)