From: Guillaume Pellerin Date: Thu, 31 Dec 2015 16:59:11 +0000 (+0100) Subject: cleanup seminar media during import X-Git-Tag: 2.8.1-pro~254 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=b1200faf01dd086d6b05339481fae44418b7885d;p=teleforma.git cleanup seminar media during import --- diff --git a/teleforma/management/commands/teleforma-import-seminar-media-update.py b/teleforma/management/commands/teleforma-import-seminar-media-update.py index 766e135d..1624927f 100644 --- a/teleforma/management/commands/teleforma-import-seminar-media-update.py +++ b/teleforma/management/commands/teleforma-import-seminar-media-update.py @@ -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)