Skip to content
Snippets Groups Projects
Commit 7acff0a3 authored by Albert St. Aubin's avatar Albert St. Aubin
Browse files

correct check for enrollment on an entitlement

[LEARNER-4484]
parent 9bddcf55
No related branches found
No related tags found
No related merge requests found
......@@ -389,13 +389,17 @@ def get_fulfillable_course_runs_for_entitlement(entitlement, course_runs):
search_time = datetime.datetime.now(UTC)
for course_run in course_runs:
course_id = CourseKey.from_string(course_run.get('key'))
is_enrolled = CourseEnrollment.is_enrolled(entitlement.user, course_id)
(user_enrollment_mode, is_active) = CourseEnrollment.enrollment_mode_for_user(
user=entitlement.user,
course_id=course_id
)
is_enrolled_in_mode = user_enrollment_mode == entitlement.mode
if is_course_run_entitlement_fulfillable(course_id, entitlement, search_time):
if (is_enrolled and
if (is_enrolled_in_mode and
entitlement.enrollment_course_run and
course_id == entitlement.enrollment_course_run.course_id):
enrollable_sessions.append(course_run)
elif not is_enrolled:
elif not is_enrolled_in_mode:
enrollable_sessions.append(course_run)
enrollable_sessions.sort(key=lambda session: session.get('start'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment