7
7
from common .djangoapps .course_action_state .models import CourseRerunState
8
8
from django .db .models .signals import post_save
9
9
from django .dispatch import receiver
10
+ from xmodule .modulestore .django import SignalHandler
11
+
10
12
from ol_openedx_course_sync .models import CourseSyncMap , CourseSyncParentOrg
11
13
from ol_openedx_course_sync .tasks import async_course_sync
12
- from xmodule . modulestore . django import SignalHandler
14
+ from ol_openedx_course_sync . constants import COURSE_RERUN_STATE_SUCCEEDED
13
15
14
16
log = logging .getLogger (__name__ )
15
17
@@ -32,23 +34,23 @@ def listen_for_course_publish(
32
34
return
33
35
34
36
source_course = str (course_sync_map .source_course )
35
- user_id = 2
37
+ user_id = None
36
38
for target_course_key in course_sync_map .target_courses .split ("," ):
37
39
log .info (
38
40
"Initializing async course content sync from %s to %s" ,
39
41
source_course ,
40
42
target_course_key ,
41
43
)
42
44
# Call the async task to copy the course content
43
- async_course_sync . delay (user_id , source_course , target_course_key )
45
+ async_course_sync (user_id , source_course , target_course_key )
44
46
45
47
46
48
@receiver (post_save , sender = CourseRerunState )
47
49
def listen_for_course_rerun_state_post_save (sender , instance , ** kwargs ): # noqa: ARG001
48
50
"""
49
51
Listen for `CourseRerunState` post_save and update target courses in `CourseSyncMap`
50
52
"""
51
- if instance .state != "succeeded" :
53
+ if instance .state != COURSE_RERUN_STATE_SUCCEEDED :
52
54
return
53
55
54
56
if not CourseSyncParentOrg .objects .filter (
0 commit comments