Merge pull request #18876 from edx/waheed/LEARNER-6313-fix-expire-entitlement-on-switching-session

Fix entitlement expiring on switching session.
This commit is contained in:
Waheed Ahmed
2018-09-04 18:01:54 +05:00
committed by GitHub

View File

@@ -414,17 +414,16 @@ class CourseEntitlement(TimeStampedModel):
@classmethod
def unenroll_entitlement(cls, course_enrollment, skip_refund):
"""
Un-enroll the user from entitlement and refund.
Un-enroll the user from entitlement and refund if needed.
"""
course_uuid = get_course_uuid_for_course(course_enrollment.course_id)
course_entitlement = cls.get_entitlement_if_active(course_enrollment.user, course_uuid)
if course_entitlement and course_entitlement.enrollment_course_run == course_enrollment:
course_entitlement.set_enrollment(None)
if not skip_refund and course_entitlement.is_entitlement_refundable():
course_entitlement.expire_entitlement()
course_entitlement.refund()
course_entitlement.expire_entitlement()
def refund(self):
"""
Initiate refund process for the entitlement.