From 0ca070a7a2974ccf5dc7474c52bc838f925aceec Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 29 May 2026 10:33:11 +0200 Subject: [PATCH] simplify test, better poster --- lib/pdfannotator | 2 +- .../teleforma-import-conferences-4.py | 33 +++++++------------ 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/lib/pdfannotator b/lib/pdfannotator index 70e1f183..1f161760 160000 --- a/lib/pdfannotator +++ b/lib/pdfannotator @@ -1 +1 @@ -Subproject commit 70e1f1833f63cb9105659b431357be580cdfc659 +Subproject commit 1f161760779798d79a9c0c073f15044c2bcc6e46 diff --git a/teleforma/management/commands/teleforma-import-conferences-4.py b/teleforma/management/commands/teleforma-import-conferences-4.py index 89e599ed..65ab67db 100644 --- a/teleforma/management/commands/teleforma-import-conferences-4.py +++ b/teleforma/management/commands/teleforma-import-conferences-4.py @@ -58,23 +58,19 @@ class Command(BaseCommand): str(conference.course_type)]), conference.public_id]) - # check - exist = False - if conference.media.all(): - exist = True - - streaming = False - try: - stations = conference.station.filter(started=True, public_id=public_id) - if stations: - streaming = True - except: - pass - - # import - if os.path.exists(conf_dir) and not exist and not streaming: + if (os.path.exists(conf_dir) and + not streaming and + not conference.media.all() and + not conference.station.filter(started=True, public_id=public_id) + ): + files = os.listdir(conf_dir) + for file in files: + name, ext = os.path.splitext(file) + if ext[1:] in self.image_formats: + poster_file = rel_path + for media_format in self.media_formats: media = Media(conference=conference) media.course = conference.course @@ -88,12 +84,6 @@ class Command(BaseCommand): full_path = conf_dir + os.sep + file rel_path = full_path.replace(settings.MEDIA_ROOT, "") - # POSTER - if ext[1:] in self.image_formats: - media.poster_file = rel_path - logger.logger.info(rel_path) - - # MEDIA FILE if ext[1:] in self.media_formats: media.file = rel_path media.save() @@ -101,6 +91,7 @@ class Command(BaseCommand): with open(full_path, 'rb') as f: media.file_s3.save(filename, File(f)) media.set_mime_type() + media.poster_file = poster_file media.save() logger.logger.info(rel_path) -- 2.47.3