From 3e5bbe99292d6d7fff052ee43fa374c7f85a6538 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Sun, 14 Nov 2021 19:18:47 +0100 Subject: [PATCH] add date limit --- bin | 2 +- lib/pdfannotator | 2 +- .../teleforma-import-conferences-create-2.py | 15 +++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bin b/bin index c5d2023d..52d01bc8 160000 --- a/bin +++ b/bin @@ -1 +1 @@ -Subproject commit c5d2023de2f038cb865a148076a4dc4ec24efaf7 +Subproject commit 52d01bc8d0ec34d96ae3751fa5709a8ae05066fd diff --git a/lib/pdfannotator b/lib/pdfannotator index c6b95327..ce69eca1 160000 --- a/lib/pdfannotator +++ b/lib/pdfannotator @@ -1 +1 @@ -Subproject commit c6b953270e4e8a7d97853d7a784f8e6df9ed9c53 +Subproject commit ce69eca18a6f5b8774215725fd6b42534f13412f diff --git a/teleforma/management/commands/teleforma-import-conferences-create-2.py b/teleforma/management/commands/teleforma-import-conferences-create-2.py index c83e1d36..b79c997a 100644 --- a/teleforma/management/commands/teleforma-import-conferences-create-2.py +++ b/teleforma/management/commands/teleforma-import-conferences-create-2.py @@ -38,6 +38,7 @@ class Command(BaseCommand): period_name = args[2] log_file = args[3] logger = Logger(log_file) + datetime_limit = datetime.datetime(year=2021, month=8, day=1) organization = Organization.objects.get(name=organization_name) department = Department.objects.get(name=department_name, @@ -57,24 +58,26 @@ class Command(BaseCommand): public_id = root_list[-1] course = root_list[-2] course_id = course.split(self.spacer)[0] - course_type = course.split(self.spacer)[1].lower() + course_type = course.split(self.spacer)[1].lower().capitalize() date = root_list[-3] department_name = root_list[-4] organization_name = root_list[-5] dir = os.sep.join(root_list[-5:]) path = dir + os.sep + filename + abs_path = root + os.sep + filename collection_id = '_'.join([department_name, course_id, course_type]) + mtime = os.path.getmtime(abs_path) + conf_datetime = datetime.datetime.fromtimestamp(mtime) conferences = Conference.objects.filter(public_id=public_id) if conferences: conference = conferences[0] - else: + elif conf_datetime > datetime_limit: courses = Course.objects.filter(code=course_id) + print(course_id) + print(path) course_type_obj = CourseType.objects.get(name=course_type) period_obj = Period.objects.get(name=period_name) - mtime = os.path.getmtime(path) - conf_datetime = datetime.datetime.fromtimestamp(mtime) - course_obj = courses[0] conference = Conference(public_id=public_id) conference.course = course_obj @@ -83,7 +86,7 @@ class Command(BaseCommand): conference.date_begin = conf_datetime conference.save() - if department: + if department and conf_datetime > datetime_limit: conference = Conference.objects.get(public_id=public_id) department = Department.objects.get(name=department_name, organization=organization) -- 2.39.5