From 98ebc3a74645a6ce936df91c20e7d1b9b01d93d5 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Sat, 9 May 2026 18:15:02 +0200 Subject: [PATCH] update import 3 command to put s3 files --- lib/pdfannotator | 2 +- .../commands/teleforma-import-conferences-3.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/pdfannotator b/lib/pdfannotator index 1f161760..70e1f183 160000 --- a/lib/pdfannotator +++ b/lib/pdfannotator @@ -1 +1 @@ -Subproject commit 1f161760779798d79a9c0c073f15044c2bcc6e46 +Subproject commit 70e1f1833f63cb9105659b431357be580cdfc659 diff --git a/teleforma/management/commands/teleforma-import-conferences-3.py b/teleforma/management/commands/teleforma-import-conferences-3.py index 95c12ede..b5fb150f 100644 --- a/teleforma/management/commands/teleforma-import-conferences-3.py +++ b/teleforma/management/commands/teleforma-import-conferences-3.py @@ -4,6 +4,7 @@ from django.core.management.base import BaseCommand, CommandError from django.contrib.auth.models import User from django.template.defaultfilters import slugify from django.core.files import File +from django.core.files.base import ContentFile from teleforma.models import * import logging import os @@ -67,7 +68,7 @@ class Command(BaseCommand): organization_name = root_list[-5] dir = os.sep.join(root_list[-5:]) path = dir + os.sep + filename - + if Conference.objects.filter(public_id=public_id) and department: conference = Conference.objects.get(public_id=public_id) department = Department.objects.get(name=department_name, @@ -90,15 +91,12 @@ class Command(BaseCommand): if not exist and not streaming: # ORIGINAL MEDIA media = Media(conference=conference) - media_file = open(path, 'rb') - media.s3_file = File(media_file) media.course = conference.course media.period = conference.period media.course_type = conference.course_type media.type = ext media.is_published = False - media.set_mime_type() - + files = os.listdir(root) # POSTER @@ -118,6 +116,13 @@ class Command(BaseCommand): media.poster_file = dir + os.sep + file break + media.save() + filename = os.path.split(path)[1] + print(filename) + with open(settings.MEDIA_ROOT + os.sep + path, 'rb') as f: + media.file_s3.save(filename, File(f)) + + media.set_mime_type() media.save() conference.save() -- 2.47.3