From b09f4fabf11154209394b1a2ee5f3b60af45d242 Mon Sep 17 00:00:00 2001 From: Harry Rein Date: Thu, 21 Dec 2017 15:29:53 -0500 Subject: [PATCH] Show more sessions coming soon for entitlements without sessions. --- .../course_entitlement.underscore | 60 ++++++++++--------- openedx/core/djangoapps/catalog/utils.py | 15 ++++- openedx/core/djangoapps/programs/utils.py | 3 +- 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/lms/templates/learner_dashboard/course_entitlement.underscore b/lms/templates/learner_dashboard/course_entitlement.underscore index df19ff6855..666e67883d 100644 --- a/lms/templates/learner_dashboard/course_entitlement.underscore +++ b/lms/templates/learner_dashboard/course_entitlement.underscore @@ -1,33 +1,39 @@
- <% if (currentSessionId) { %> - <%- gettext('Change to a different session or leave the current session.')%> + <% if (availableSessions.length === 0) { %> + <%- gettext('More sessions coming soon.') %> <% } else { %> - <%- gettext('To access the course, select a session.')%> + <% if (currentSessionId) { %> + <%- gettext('Change to a different session or leave the current session.')%> + <% } else { %> + <%- gettext('To access the course, select a session.')%> + <% } %> <% } %>
-
- - -
+ <% if (availableSessions.length !== 0) { %> +
+ + +
+ <% } %>
diff --git a/openedx/core/djangoapps/catalog/utils.py b/openedx/core/djangoapps/catalog/utils.py index f144ab1a7f..d168bef6a9 100644 --- a/openedx/core/djangoapps/catalog/utils.py +++ b/openedx/core/djangoapps/catalog/utils.py @@ -245,19 +245,28 @@ def get_course_runs_for_course(course_uuid): def get_visible_course_runs_for_entitlement(entitlement): """ - We only want to show courses for a particular entitlement that: + Returns only the course runs that the user can currently enroll in. + """ + sessions_for_course = get_course_runs_for_course(entitlement.course_uuid) + return get_fulfillable_course_runs_for_entitlement(entitlement, sessions_for_course) + + +def get_fulfillable_course_runs_for_entitlement(entitlement, course_runs): + """ + Takes a list of course runs and returns only the course runs that: 1) Are currently running or in the future 2) A user can enroll in 3) A user can upgrade in 4) Are published + + These are the only sessions that can be selected for an entitlement. """ - sessions_for_course = get_course_runs_for_course(entitlement.course_uuid) enrollable_sessions = [] # Only show published course runs that can still be enrolled and upgraded now = datetime.datetime.now(UTC) - for course_run in sessions_for_course: + for course_run in course_runs: # Only courses that have not ended will be displayed run_start = course_run.get('start') run_end = course_run.get('end') diff --git a/openedx/core/djangoapps/programs/utils.py b/openedx/core/djangoapps/programs/utils.py index 22b16a7fe0..1b24970a99 100644 --- a/openedx/core/djangoapps/programs/utils.py +++ b/openedx/core/djangoapps/programs/utils.py @@ -24,7 +24,7 @@ from lms.djangoapps.certificates import api as certificate_api from lms.djangoapps.commerce.utils import EcommerceService from lms.djangoapps.courseware.access import has_access from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory -from openedx.core.djangoapps.catalog.utils import get_programs +from openedx.core.djangoapps.catalog.utils import get_programs, get_fulfillable_course_runs_for_entitlement from openedx.core.djangoapps.commerce.utils import ecommerce_api_client from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from openedx.core.djangoapps.credentials.utils import get_credentials @@ -230,6 +230,7 @@ class ProgramProgressMeter(object): elif self._is_course_enrolled(course) or active_entitlement: # Show all currently enrolled courses and active entitlements as in progress if active_entitlement: + course['course_runs'] = get_fulfillable_course_runs_for_entitlement(active_entitlement, course['course_runs']) course['user_entitlement'] = active_entitlement.to_dict() course['enroll_url'] = reverse( 'entitlements_api:v1:enrollments',