22This module contains signals / handlers related to programs.
33"""
44
5-
65import logging
76
87from django .dispatch import receiver
1413 COURSE_CERT_AWARDED ,
1514 COURSE_CERT_CHANGED ,
1615 COURSE_CERT_DATE_CHANGE ,
17- COURSE_CERT_REVOKED
16+ COURSE_CERT_REVOKED ,
1817)
1918
2019LOGGER = logging .getLogger (__name__ )
@@ -39,11 +38,10 @@ def handle_course_cert_awarded(sender, user, course_key, mode, status, **kwargs)
3938 if not is_credentials_enabled ():
4039 return
4140
42- LOGGER .debug (
43- f"Handling COURSE_CERT_AWARDED: user={ user } , course_key={ course_key } , mode={ mode } , status={ status } "
44- )
41+ LOGGER .debug (f"Handling COURSE_CERT_AWARDED: user={ user } , course_key={ course_key } , mode={ mode } , status={ status } " )
4542 # import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
4643 from openedx .core .djangoapps .programs .tasks import award_program_certificates
44+
4745 award_program_certificates .delay (user .username )
4846
4947
@@ -68,7 +66,7 @@ def handle_course_cert_changed(sender, user, course_key, mode, status, **kwargs)
6866 Returns:
6967 None
7068 """
71- verbose = kwargs .get (' verbose' , False )
69+ verbose = kwargs .get (" verbose" , False )
7270 if verbose :
7371 LOGGER .info (
7472 f"Starting handle_course_cert_changed with params: sender [{ sender } ], user [{ user } ], course_key "
@@ -87,6 +85,7 @@ def handle_course_cert_changed(sender, user, course_key, mode, status, **kwargs)
8785 LOGGER .debug (f"Handling COURSE_CERT_CHANGED: user={ user } , course_key={ course_key } , mode={ mode } , status={ status } " )
8886 # import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
8987 from openedx .core .djangoapps .programs .tasks import award_course_certificate
88+
9089 award_course_certificate .delay (user .username , str (course_key ))
9190
9291
@@ -112,16 +111,16 @@ def handle_course_cert_revoked(sender, user, course_key, mode, status, **kwargs)
112111 LOGGER .info (f"Handling COURSE_CERT_REVOKED: user={ user } , course_key={ course_key } , mode={ mode } , status={ status } " )
113112 # import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
114113 from openedx .core .djangoapps .programs .tasks import revoke_program_certificates
114+
115115 revoke_program_certificates .delay (user .username , str (course_key ))
116116
117117
118- @receiver (COURSE_CERT_DATE_CHANGE , dispatch_uid = ' course_certificate_date_change_handler' )
118+ @receiver (COURSE_CERT_DATE_CHANGE , dispatch_uid = " course_certificate_date_change_handler" )
119119def handle_course_cert_date_change (sender , course_key , ** kwargs ): # pylint: disable=unused-argument
120120 """
121121 When a course run's configuration has been updated, and the system has detected an update related to the display
122122 behavior or availability date of the certificates issued in that course, we should enqueue celery tasks responsible
123123 for:
124- - updating the `visible_date` attribute of any previously awarded certificates the Credentials IDA manages
125124 - updating the certificate available date of the course run's course certificate configuration in Credentials
126125
127126 Args:
@@ -137,6 +136,7 @@ def handle_course_cert_date_change(sender, course_key, **kwargs): # pylint: dis
137136 LOGGER .info (f"Handling COURSE_CERT_DATE_CHANGE for course { course_key } " )
138137 # import here, because signal is registered at startup, but items in tasks are not yet loaded
139138 from openedx .core .djangoapps .programs .tasks import update_certificate_available_date_on_course_update
139+
140140 update_certificate_available_date_on_course_update .delay (str (course_key ))
141141
142142
@@ -161,4 +161,5 @@ def handle_course_pacing_change(sender, updated_course_overview, **kwargs): # p
161161 LOGGER .info (f"Handling COURSE_PACING_CHANGED for course { course_id } " )
162162 # import here, because signal is registered at startup, but items in tasks are not yet loaded
163163 from openedx .core .djangoapps .programs .tasks import update_certificate_available_date_on_course_update
164+
164165 update_certificate_available_date_on_course_update .delay (course_id )
0 commit comments