-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2190 from openedx/pwnage101/ENT-9213
feat: emit learner credit unenrollment event
- Loading branch information
Showing
15 changed files
with
237 additions
and
20 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
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
Your project description goes here. | ||
""" | ||
|
||
__version__ = "4.24.0" | ||
__version__ = "4.25.0" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
""" | ||
Functions for serializing and emiting Open edX event bus signals. | ||
""" | ||
from openedx_events.enterprise.data import ( | ||
EnterpriseCourseEnrollment, | ||
EnterpriseCustomerUser, | ||
LearnerCreditEnterpriseCourseEnrollment, | ||
) | ||
from openedx_events.enterprise.signals import LEARNER_CREDIT_COURSE_ENROLLMENT_REVOKED | ||
|
||
|
||
def serialize_learner_credit_course_enrollment(learner_credit_course_enrollment): | ||
""" | ||
Serializes the ``LearnerCreditEnterpriseCourseEnrollment`` into a defined set of attributes | ||
for use in the event-bus signal. | ||
""" | ||
enterprise_course_enrollment = learner_credit_course_enrollment.enterprise_course_enrollment | ||
enterprise_customer_user = enterprise_course_enrollment.enterprise_customer_user | ||
|
||
enterprise_customer_user_data = EnterpriseCustomerUser( | ||
id=enterprise_customer_user.id, | ||
created=enterprise_customer_user.created, | ||
modified=enterprise_customer_user.modified, | ||
enterprise_customer_uuid=enterprise_customer_user.enterprise_customer.uuid, | ||
user_id=enterprise_customer_user.user_id, | ||
active=enterprise_customer_user.active, | ||
linked=enterprise_customer_user.linked, | ||
is_relinkable=enterprise_customer_user.is_relinkable, | ||
invite_key=enterprise_customer_user.invite_key.uuid if enterprise_customer_user.invite_key else None, | ||
should_inactivate_other_customers=enterprise_customer_user.should_inactivate_other_customers, | ||
) | ||
enterprise_course_enrollment_data = EnterpriseCourseEnrollment( | ||
id=enterprise_course_enrollment.id, | ||
created=enterprise_course_enrollment.created, | ||
modified=enterprise_course_enrollment.modified, | ||
enterprise_customer_user=enterprise_customer_user_data, | ||
course_id=enterprise_course_enrollment.course_id, | ||
saved_for_later=enterprise_course_enrollment.saved_for_later, | ||
source_slug=enterprise_course_enrollment.source.slug if enterprise_course_enrollment.source else None, | ||
unenrolled=enterprise_course_enrollment.unenrolled, | ||
unenrolled_at=enterprise_course_enrollment.unenrolled_at, | ||
) | ||
data = LearnerCreditEnterpriseCourseEnrollment( | ||
uuid=learner_credit_course_enrollment.uuid, | ||
created=learner_credit_course_enrollment.created, | ||
modified=learner_credit_course_enrollment.modified, | ||
fulfillment_type=learner_credit_course_enrollment.fulfillment_type, | ||
enterprise_course_entitlement_uuid=( | ||
learner_credit_course_enrollment.enterprise_course_entitlement.uuid | ||
if learner_credit_course_enrollment.enterprise_course_entitlement | ||
else None | ||
), | ||
enterprise_course_enrollment=enterprise_course_enrollment_data, | ||
is_revoked=learner_credit_course_enrollment.is_revoked, | ||
transaction_id=learner_credit_course_enrollment.transaction_id, | ||
) | ||
return data | ||
|
||
|
||
def send_learner_credit_course_enrollment_revoked_event(learner_credit_course_enrollment): | ||
""" | ||
Sends the LEARNER_CREDIT_COURSE_ENROLLMENT_REVOKED openedx event. | ||
Args: | ||
learner_credit_course_enrollment (enterprise.models.LearnerCreditEnterpriseCourseEnrollment): | ||
An enterprise learner credit fulfillment record that was revoked. | ||
""" | ||
LEARNER_CREDIT_COURSE_ENROLLMENT_REVOKED.send_event( | ||
learner_credit_course_enrollment=serialize_learner_credit_course_enrollment(learner_credit_course_enrollment), | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ edx-tincan-py35 | |
edx-toggles | ||
jsondiff | ||
jsonfield | ||
openedx-events | ||
paramiko | ||
path.py | ||
pillow | ||
|
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
|
||
|
||
|
||
|
||
# A central location for most common version constraints | ||
# (across edx repos) for pip-installation. | ||
# | ||
|
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
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
Oops, something went wrong.