]> git.parisson.com Git - teleforma.git/commitdiff
simplify test, better poster
authorGuillaume Pellerin <guillaume.pellerin@parisson.com>
Fri, 29 May 2026 08:33:11 +0000 (10:33 +0200)
committerGuillaume Pellerin <guillaume.pellerin@parisson.com>
Fri, 29 May 2026 08:33:11 +0000 (10:33 +0200)
lib/pdfannotator
teleforma/management/commands/teleforma-import-conferences-4.py

index 70e1f1833f63cb9105659b431357be580cdfc659..1f161760779798d79a9c0c073f15044c2bcc6e46 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 70e1f1833f63cb9105659b431357be580cdfc659
+Subproject commit 1f161760779798d79a9c0c073f15044c2bcc6e46
index 89e599ed1c521ed4b1a1bee9f42e6f6bd34c4a98..65ab67dbd5d478eed3fa672d9b3a618d8be4d3fe 100644 (file)
@@ -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)