From: Guillaume Pellerin Date: Thu, 31 Dec 2015 22:25:14 +0000 (+0100) Subject: fix media delete X-Git-Tag: 2.8.1-pro~252 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=2b62fd3d8ebe3e8bfa6748e95e45f0c9b3339d06;p=teleforma.git fix media delete --- diff --git a/teleforma/management/commands/teleforma-import-seminar-media-update.py b/teleforma/management/commands/teleforma-import-seminar-media-update.py index 8fd2d509..969909ff 100644 --- a/teleforma/management/commands/teleforma-import-seminar-media-update.py +++ b/teleforma/management/commands/teleforma-import-seminar-media-update.py @@ -166,11 +166,6 @@ class Command(BaseCommand): seminar.status = 1 seminar.save() - 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: collection = MediaCollection(code=collection_id,title=collection_id) @@ -182,6 +177,11 @@ class Command(BaseCommand): item = self.get_item(collection, id) item.title = name + # cleanup old media + for media in seminar.medias.all(): + if not period.name in item.code: + seminar.medias.remove(media) + if not item.file == path: logger.logger.info(seminar.public_url()) logger.logger.info(path)