forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: [ACI-972] extract event bus event to another function (#2552)
Co-authored-by: Andrii <[email protected]>
- Loading branch information
1 parent
598d1b5
commit 0095376
Showing
3 changed files
with
54 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from openedx_events.learning.data import ( | ||
CcxCourseData, | ||
CcxCoursePassingStatusData, | ||
CourseData, | ||
CoursePassingStatusData, | ||
UserData, | ||
UserPersonalData | ||
) | ||
from openedx_events.learning.signals import CCX_COURSE_PASSING_STATUS_UPDATED, COURSE_PASSING_STATUS_UPDATED | ||
|
||
|
||
def emit_course_passing_status_update(user, course_id, is_passing): | ||
if hasattr(course_id, 'ccx'): | ||
CCX_COURSE_PASSING_STATUS_UPDATED.send_event( | ||
course_passing_status=CcxCoursePassingStatusData( | ||
is_passing=is_passing, | ||
user=UserData( | ||
pii=UserPersonalData( | ||
username=user.username, | ||
email=user.email, | ||
name=user.get_full_name(), | ||
), | ||
id=user.id, | ||
is_active=user.is_active, | ||
), | ||
course=CcxCourseData( | ||
ccx_course_key=course_id, | ||
master_course_key=course_id.to_course_locator(), | ||
), | ||
) | ||
) | ||
else: | ||
COURSE_PASSING_STATUS_UPDATED.send_event( | ||
course_passing_status=CoursePassingStatusData( | ||
is_passing=is_passing, | ||
user=UserData( | ||
pii=UserPersonalData( | ||
username=user.username, | ||
email=user.email, | ||
name=user.get_full_name(), | ||
), | ||
id=user.id, | ||
is_active=user.is_active, | ||
), | ||
course=CourseData( | ||
course_key=course_id, | ||
), | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters