From 25076e6a9210789734f7cd26bbb71b6741358f29 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Fri, 8 Dec 2017 16:44:41 -0500 Subject: [PATCH] Show related programs when unenrolled On the course dashboard, show related programs to your course even if you are not enrolled in a current session. LEARNER-3504 --- common/djangoapps/student/tests/test_views.py | 10 ++++++++-- lms/templates/dashboard.html | 2 +- lms/templates/dashboard/_dashboard_course_listing.html | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common/djangoapps/student/tests/test_views.py b/common/djangoapps/student/tests/test_views.py index f873c1c4ae..d6bee4b3de 100644 --- a/common/djangoapps/student/tests/test_views.py +++ b/common/djangoapps/student/tests/test_views.py @@ -19,6 +19,7 @@ from opaque_keys import InvalidKeyError from pyquery import PyQuery as pq from entitlements.tests.factories import CourseEntitlementFactory +from openedx.core.djangoapps.catalog.tests.factories import ProgramFactory from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory from student.cookies import get_user_info_cookie_data @@ -339,16 +340,20 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): response = self.client.get(reverse('dashboard')) self.assertNotIn('
', response.content) + @patch('openedx.core.djangoapps.programs.utils.get_programs') @patch('student.views.get_course_runs_for_course') @patch.object(CourseOverview, 'get_from_id') - def test_unfulfilled_entitlement(self, mock_course_overview, mock_course_runs): + def test_unfulfilled_entitlement(self, mock_course_overview, mock_course_runs, mock_get_programs): """ When a learner has an unfulfilled entitlement, their course dashboard should have: - a hidden 'View Course' button - the text 'In order to view the course you must select a session:' - an unhidden course-entitlement-selection-container + - a related programs message """ - CourseEntitlementFactory(user=self.user) + program = ProgramFactory() + CourseEntitlementFactory(user=self.user, course_uuid=program['courses'][0]['uuid']) + mock_get_programs.return_value = [program] mock_course_overview.return_value = CourseOverviewFactory(start=self.TOMORROW) mock_course_runs.return_value = [ { @@ -362,6 +367,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): self.assertIn('class="enter-course hidden"', response.content) self.assertIn('You must select a session to access the course.', response.content) self.assertIn('
', response.content) + self.assertIn('Related Programs:', response.content) @patch('student.views.get_course_runs_for_course') @patch.object(CourseOverview, 'get_from_id') diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html index c60337be24..f81ddcb82c 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -163,7 +163,7 @@ from student.models import CourseEnrollment is_course_blocked = (session_id in block_courses) course_verification_status = verification_status_by_course.get(session_id, {}) course_requirements = courses_requirements_not_met.get(session_id) - related_programs = inverted_programs.get(unicode(session_id)) + related_programs = inverted_programs.get(unicode(entitlement.course_uuid if entitlement else session_id)) show_consent_link = (session_id in consent_required_courses) course_overview = enrollment.course_overview %> diff --git a/lms/templates/dashboard/_dashboard_course_listing.html b/lms/templates/dashboard/_dashboard_course_listing.html index dc4e045e28..de4b85303b 100644 --- a/lms/templates/dashboard/_dashboard_course_listing.html +++ b/lms/templates/dashboard/_dashboard_course_listing.html @@ -299,7 +299,7 @@ from util.course import get_link_for_about_page, get_encoded_course_sharing_utm_ %endif - % if related_programs and not entitlement: + % if related_programs: