@@ -27,16 +27,21 @@ def listen_for_course_publish(
27
27
return
28
28
29
29
course_sync_map = CourseSyncMap .objects .filter (source_course = course_key ).first ()
30
- if course_sync_map and course_sync_map .target_courses :
31
- source_course = str (course_sync_map .source_course )
32
- user_id = 2
33
- for target_course_key in course_sync_map .target_courses .split ("," ):
34
- # Call the async task to copy the course content
35
- async_course_sync .delay (user_id , source_course , target_course_key )
36
- else :
37
- log .warning ("No mapping found for course %s. Skipping copy." , course_key .id )
30
+ if not (course_sync_map and course_sync_map .target_courses ):
31
+ log .info ("No mapping found for course %s. Skipping copy." , course_key .id )
38
32
return
39
33
34
+ source_course = str (course_sync_map .source_course )
35
+ user_id = 2
36
+ for target_course_key in course_sync_map .target_courses .split ("," ):
37
+ log .info (
38
+ "Initializing async course content sync from %s to %s" ,
39
+ source_course ,
40
+ target_course_key ,
41
+ )
42
+ # Call the async task to copy the course content
43
+ async_course_sync .delay (user_id , source_course , target_course_key )
44
+
40
45
41
46
@receiver (post_save , sender = CourseRerunState )
42
47
def listen_for_course_rerun_state_post_save (sender , instance , ** kwargs ): # noqa: ARG001
@@ -55,6 +60,10 @@ def listen_for_course_rerun_state_post_save(sender, instance, **kwargs): # noqa
55
60
if CourseSyncMap .objects .filter (
56
61
target_courses__contains = str (instance .source_course_key )
57
62
).exists ():
63
+ log .warning (
64
+ "Course %s is already a target course. Skipping." ,
65
+ instance .source_course_key ,
66
+ )
58
67
return
59
68
60
69
course_sync_map , _ = CourseSyncMap .objects .get_or_create (
@@ -68,3 +77,8 @@ def listen_for_course_rerun_state_post_save(sender, instance, **kwargs): # noqa
68
77
target_courses .append (str (instance .course_key ))
69
78
course_sync_map .target_courses = "," .join (target_courses )
70
79
course_sync_map .save ()
80
+ log .info (
81
+ "Added course %s to target courses for %s" ,
82
+ instance .course_key ,
83
+ instance .source_course_key ,
84
+ )
0 commit comments