From 711343a7c7be69a2724c593388517b57e7ccddbc Mon Sep 17 00:00:00 2001 From: Waheed Ahmed Date: Tue, 4 Sep 2018 11:38:58 +0500 Subject: [PATCH] Fix entitlement expiring on switching session. LEARNER-6313 --- common/djangoapps/entitlements/models.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/djangoapps/entitlements/models.py b/common/djangoapps/entitlements/models.py index f9b532ea40..71ebf29af6 100644 --- a/common/djangoapps/entitlements/models.py +++ b/common/djangoapps/entitlements/models.py @@ -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.