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 e479ae9f9d..b3b0973e14 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -167,7 +167,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: