Show more sessions coming soon on course dashboard.
LEARNER-3808 Ensures that users can see their entitlement purchase whether there are available sessions or not. Notifies them with a message stating that more sessions are coming soon, as is currently implemented on the programs dashboard.
This commit is contained in:
@@ -133,7 +133,6 @@ class CourseEntitlement(TimeStampedModel):
|
||||
"""
|
||||
Represents a Student's Entitlement to a Course Run for a given Course.
|
||||
"""
|
||||
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL)
|
||||
uuid = models.UUIDField(default=uuid_tools.uuid4, editable=False, unique=True)
|
||||
course_uuid = models.UUIDField(help_text='UUID for the Course, not the Course Run')
|
||||
|
||||
@@ -347,9 +347,10 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
self.assertNotIn('<div class="prerequisites">', response.content)
|
||||
|
||||
@patch('openedx.core.djangoapps.programs.utils.get_programs')
|
||||
@patch('student.views.get_visible_course_runs_for_entitlement')
|
||||
@patch('student.views.get_visible_sessions_for_entitlement')
|
||||
@patch('student.views.get_pseudo_session_for_entitlement')
|
||||
@patch.object(CourseOverview, 'get_from_id')
|
||||
def test_unfulfilled_entitlement(self, mock_course_overview, mock_course_runs, mock_get_programs):
|
||||
def test_unfulfilled_entitlement(self, mock_course_overview, mock_pseudo_session, mock_course_runs, mock_get_programs):
|
||||
"""
|
||||
When a learner has an unfulfilled entitlement, their course dashboard should have:
|
||||
- a hidden 'View Course' button
|
||||
@@ -369,13 +370,17 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
'type': 'verified'
|
||||
}
|
||||
]
|
||||
mock_pseudo_session.return_value = {
|
||||
'key': 'course-v1:FAKE+FA1-MA1.X+3T2017',
|
||||
'type': 'verified'
|
||||
}
|
||||
response = self.client.get(self.path)
|
||||
self.assertIn('class="enter-course hidden"', response.content)
|
||||
self.assertIn('You must select a session to access the course.', response.content)
|
||||
self.assertIn('<div class="course-entitlement-selection-container ">', response.content)
|
||||
self.assertIn('Related Programs:', response.content)
|
||||
|
||||
@patch('student.views.get_visible_course_runs_for_entitlement')
|
||||
@patch('student.views.get_visible_sessions_for_entitlement')
|
||||
@patch.object(CourseOverview, 'get_from_id')
|
||||
def test_unfulfilled_expired_entitlement(self, mock_course_overview, mock_course_runs):
|
||||
"""
|
||||
@@ -468,7 +473,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
# self.assertNotIn(noAvailableSessions, response.content)
|
||||
|
||||
@patch('openedx.core.djangoapps.programs.utils.get_programs')
|
||||
@patch('student.views.get_visible_course_runs_for_entitlement')
|
||||
@patch('student.views.get_visible_sessions_for_entitlement')
|
||||
@patch.object(CourseOverview, 'get_from_id')
|
||||
@patch('opaque_keys.edx.keys.CourseKey.from_string')
|
||||
def test_fulfilled_entitlement(self, mock_course_key, mock_course_overview, mock_course_runs, mock_get_programs):
|
||||
@@ -505,7 +510,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
self.assertIn('Related Programs:', response.content)
|
||||
|
||||
@patch('openedx.core.djangoapps.programs.utils.get_programs')
|
||||
@patch('student.views.get_visible_course_runs_for_entitlement')
|
||||
@patch('student.views.get_visible_sessions_for_entitlement')
|
||||
@patch.object(CourseOverview, 'get_from_id')
|
||||
@patch('opaque_keys.edx.keys.CourseKey.from_string')
|
||||
def test_fulfilled_expired_entitlement(self, mock_course_key, mock_course_overview, mock_course_runs, mock_get_programs):
|
||||
|
||||
@@ -74,7 +74,9 @@ from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification
|
||||
# Note that this lives in LMS, so this dependency should be refactored.
|
||||
from notification_prefs.views import enable_notifications
|
||||
from openedx.core.djangoapps import monitoring_utils
|
||||
from openedx.core.djangoapps.catalog.utils import get_programs_with_type, get_visible_course_runs_for_entitlement
|
||||
from openedx.core.djangoapps.catalog.utils import (
|
||||
get_programs_with_type, get_visible_sessions_for_entitlement, get_pseudo_session_for_entitlement
|
||||
)
|
||||
from openedx.core.djangoapps.certificates.api import certificates_viewable_for_course
|
||||
from openedx.core.djangoapps.credit.email_utils import get_credit_provider_display_names, make_providers_strings
|
||||
from openedx.core.djangoapps.embargo import api as embargo_api
|
||||
@@ -699,12 +701,18 @@ def dashboard(request):
|
||||
course_enrollments = list(get_course_enrollments(user, site_org_whitelist, site_org_blacklist))
|
||||
|
||||
# Get the entitlements for the user and a mapping to all available sessions for that entitlement
|
||||
# If an entitlement has no available sessions, pass through a mock course overview object
|
||||
course_entitlements = list(CourseEntitlement.get_active_entitlements_for_user(user))
|
||||
course_entitlement_available_sessions = {}
|
||||
unfulfilled_entitlement_pseudo_sessions = {}
|
||||
for course_entitlement in course_entitlements:
|
||||
course_entitlement.update_expired_at()
|
||||
valid_course_runs = get_visible_course_runs_for_entitlement(course_entitlement)
|
||||
course_entitlement_available_sessions[str(course_entitlement.uuid)] = valid_course_runs
|
||||
available_sessions = get_visible_sessions_for_entitlement(course_entitlement)
|
||||
course_entitlement_available_sessions[str(course_entitlement.uuid)] = available_sessions
|
||||
if not course_entitlement.enrollment_course_run:
|
||||
# Unfulfilled entitlements need a mock session for metadata
|
||||
pseudo_session = get_pseudo_session_for_entitlement(course_entitlement)
|
||||
unfulfilled_entitlement_pseudo_sessions[str(course_entitlement.uuid)] = pseudo_session
|
||||
|
||||
# Record how many courses there are so that we can get a better
|
||||
# understanding of usage patterns on prod.
|
||||
@@ -915,6 +923,7 @@ def dashboard(request):
|
||||
'course_enrollments': course_enrollments,
|
||||
'course_entitlements': course_entitlements,
|
||||
'course_entitlement_available_sessions': course_entitlement_available_sessions,
|
||||
'unfulfilled_entitlement_pseudo_sessions': unfulfilled_entitlement_pseudo_sessions,
|
||||
'course_optouts': course_optouts,
|
||||
'banner_account_activation_message': banner_account_activation_message,
|
||||
'sidebar_account_activation_message': sidebar_account_activation_message,
|
||||
|
||||
Reference in New Issue
Block a user