]> git.parisson.com Git - teleforma.git/commitdiff
add date limit
authorGuillaume Pellerin <guillaume.pellerin@parisson.com>
Sun, 14 Nov 2021 18:18:47 +0000 (19:18 +0100)
committerGuillaume Pellerin <guillaume.pellerin@parisson.com>
Sun, 14 Nov 2021 18:18:47 +0000 (19:18 +0100)
bin
lib/pdfannotator
teleforma/management/commands/teleforma-import-conferences-create-2.py

diff --git a/bin b/bin
index c5d2023de2f038cb865a148076a4dc4ec24efaf7..52d01bc8d0ec34d96ae3751fa5709a8ae05066fd 160000 (submodule)
--- a/bin
+++ b/bin
@@ -1 +1 @@
-Subproject commit c5d2023de2f038cb865a148076a4dc4ec24efaf7
+Subproject commit 52d01bc8d0ec34d96ae3751fa5709a8ae05066fd
index c6b953270e4e8a7d97853d7a784f8e6df9ed9c53..ce69eca18a6f5b8774215725fd6b42534f13412f 160000 (submodule)
@@ -1 +1 @@
-Subproject commit c6b953270e4e8a7d97853d7a784f8e6df9ed9c53
+Subproject commit ce69eca18a6f5b8774215725fd6b42534f13412f
index c83e1d36935d5a5c3cc31dd97e2070ff40e159e4..b79c997aa0154bd9d8a0e4c5f00d0da7f5421e77 100644 (file)
@@ -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)