From c4711a909cc35a83cfede41c4dd466b9eb2c9dd9 Mon Sep 17 00:00:00 2001 From: Erick Ivan Murillo Molina Date: Wed, 21 Jun 2023 16:08:44 -0600 Subject: [PATCH] fix: valitade enrollment for programs (#42) * fix: valitade enrollment for programs * style: fixing code --- eox_hooks/actions.py | 6 +++++- eox_hooks/tests/test_actions.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/eox_hooks/actions.py b/eox_hooks/actions.py index c45d4c9..0397f4d 100644 --- a/eox_hooks/actions.py +++ b/eox_hooks/actions.py @@ -158,9 +158,13 @@ def trigger_enrollments_creation(**kwargs): if not followup_enrollments: return + followup_list = [] + for enroll in followup_enrollments: + if str(enrollment.course.course_key) != enroll['course_id']: + followup_list.append(enroll) create_enrollments_for_program.delay( - enrollment.user.pii.username, followup_enrollments, + enrollment.user.pii.username, followup_list, ) diff --git a/eox_hooks/tests/test_actions.py b/eox_hooks/tests/test_actions.py index 078af7e..af0a1e5 100644 --- a/eox_hooks/tests/test_actions.py +++ b/eox_hooks/tests/test_actions.py @@ -166,7 +166,7 @@ def test_enroll_for_program(self, get_course, create_enroll_task): other_course_settings = { "EDNX_TRIGGER_FOLLOWUP_ENROLLMENTS": [ { - "course_id": "course-v1:edX+DemoX+Demo_Course", + "course_id": "course-v1:edX+Demo123+Demo_Course", }, ], } @@ -179,7 +179,7 @@ def test_enroll_for_program(self, get_course, create_enroll_task): "test", [ { - "course_id": "course-v1:edX+DemoX+Demo_Course", + "course_id": "course-v1:edX+Demo123+Demo_Course", }, ], )