Commit 724168d6 by Albert St. Aubin

simplification pr changes

parent a4cb374b
...@@ -460,7 +460,7 @@ class ProgramDataExtender(object): ...@@ -460,7 +460,7 @@ class ProgramDataExtender(object):
) )
is_paid_seat = False is_paid_seat = False
if enrollment_mode is not None and active is not None: if enrollment_mode is not None and active is not None and active is True:
# Check all the applicable seat types # Check all the applicable seat types
# this will also check for no-id-professional as professional # this will also check for no-id-professional as professional
is_paid_seat = any(seat_type in enrollment_mode for seat_type in applicable_seat_types) is_paid_seat = any(seat_type in enrollment_mode for seat_type in applicable_seat_types)
...@@ -478,25 +478,17 @@ class ProgramDataExtender(object): ...@@ -478,25 +478,17 @@ class ProgramDataExtender(object):
bundle_variant = 'full' bundle_variant = 'full'
if is_learner_eligible_for_one_click_purchase: if is_learner_eligible_for_one_click_purchase:
for course in self.data['courses']: for course in self.data['courses']:
add_course_sku = False add_course_sku = True
unpublished_enrollment = False course_runs = course.get('course_runs', [])
unpublished_course_runs = filter(lambda run: run['status'] == 'unpublished', course['course_runs']) published_course_runs = filter(lambda run: run['status'] == 'published', course_runs)
published_course_runs = filter(lambda run: run['status'] == 'published', course['course_runs'])
if len(published_course_runs) == 1: if len(published_course_runs) == 1:
for course_run in unpublished_course_runs: for course_run in course_runs:
is_paid_seat = self._check_enrollment_for_user(course_run) is_paid_seat = self._check_enrollment_for_user(course_run)
if is_paid_seat: if is_paid_seat:
unpublished_enrollment = True add_course_sku = False
break
if not unpublished_enrollment:
course_run = published_course_runs[0]
is_paid_seat = self._check_enrollment_for_user(course_run)
if not is_paid_seat:
add_course_sku = True
else:
# There is no enrollment information for the course add the course SKU
add_course_sku = True
if add_course_sku: if add_course_sku:
for seat in published_course_runs[0]['seats']: for seat in published_course_runs[0]['seats']:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment