diff --git a/common/djangoapps/student/tests/test_views.py b/common/djangoapps/student/tests/test_views.py index ffa5c6b089022f7d61504fc69353b99d0100365e..20b00120ee01f5c2fb70c4e354cc41cd655a5474 100644 --- a/common/djangoapps/student/tests/test_views.py +++ b/common/djangoapps/student/tests/test_views.py @@ -24,6 +24,7 @@ from edx_oauth2_provider.tests.factories import (ClientFactory, TrustedClientFactory) from entitlements.tests.factories import CourseEntitlementFactory from milestones.tests.utils import MilestonesTestCaseMixin +from opaque_keys.edx.keys import CourseKey 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 @@ -377,10 +378,11 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin, program = ProgramFactory() CourseEntitlementFactory.create(user=self.user, course_uuid=program['courses'][0]['uuid']) mock_get_programs.return_value = [program] - mock_course_overview.return_value = CourseOverviewFactory.create(start=self.TOMORROW) + course_key = CourseKey.from_string('course-v1:FAKE+FA1-MA1.X+3T2017') + mock_course_overview.return_value = CourseOverviewFactory.create(start=self.TOMORROW, id=course_key) mock_course_runs.return_value = [ { - 'key': 'course-v1:FAKE+FA1-MA1.X+3T2017', + 'key': unicode(course_key), 'enrollment_end': str(self.TOMORROW), 'pacing_type': 'instructor_paced', 'type': 'verified', @@ -388,7 +390,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin, } ] mock_pseudo_session.return_value = { - 'key': 'course-v1:FAKE+FA1-MA1.X+3T2017', + 'key': unicode(course_key), 'type': 'verified' } response = self.client.get(self.path) diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py index 441417804023f74a16eb5e2ab3d8751a6f9aa8a2..ab0d3aca4bd38ac3c839cd97d8b2d19b2b05ceb8 100644 --- a/common/djangoapps/student/views/dashboard.py +++ b/common/djangoapps/student/views/dashboard.py @@ -647,10 +647,10 @@ def student_dashboard(request): staff_access = True errored_courses = modulestore().get_errored_courses() - show_courseware_links_for = frozenset( - enrollment.course_id for enrollment in course_enrollments - if has_access(request.user, 'load', enrollment.course_overview) - ) + show_courseware_links_for = { + enrollment.course_id: has_access(request.user, 'load', enrollment.course_overview) + for enrollment in course_enrollments + } # Find programs associated with course runs being displayed. This information # is passed in the template context to allow rendering of program-related diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html index 1fc45e6c1ec0fceb13d9af45c695994589289d73..22f5e529d8dbc9f5afc20ac359d4f1d0eed6d906 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -175,7 +175,7 @@ from student.models import CourseEnrollment show_email_settings = (enrollment.course_id in show_email_settings_for) session_id = enrollment.course_id - show_courseware_link = (session_id in show_courseware_links_for) + show_courseware_link = show_courseware_links_for.get(session_id, False) cert_status = cert_statuses.get(session_id) can_refund_entitlement = entitlement and entitlement.is_entitlement_refundable() can_unenroll = (not cert_status) or cert_status.get('can_unenroll') if not unfulfilled_entitlement else False diff --git a/lms/templates/dashboard/_dashboard_course_listing.html b/lms/templates/dashboard/_dashboard_course_listing.html index 680bd640c93bc2c4e724391ecd1f9d76b21d7eee..1b16d0ba3392a07eaafb96baa5af648c4af240e7 100644 --- a/lms/templates/dashboard/_dashboard_course_listing.html +++ b/lms/templates/dashboard/_dashboard_course_listing.html @@ -184,8 +184,8 @@ from util.course import get_link_for_about_page, get_encoded_course_sharing_utm_ </span> </a> % elif not is_course_blocked: - <a href="${course_target}" - class="enter-course ${'hidden' if is_unfulfilled_entitlement else ''}" + <a href="${course_target}" + class="enter-course ${'hidden' if is_unfulfilled_entitlement else ''}" data-course-key="${enrollment.course_id}"> ${_('View Course')} <span class="sr"> @@ -202,6 +202,14 @@ from util.course import get_link_for_about_page, get_encoded_course_sharing_utm_ </a> % endif % endif + % elif hasattr(show_courseware_link, 'user_message'): + <span class="enter-course-blocked" + data-course-key="${enrollment.course_id}"> + ${show_courseware_link.user_message} + <span class="sr"> + ${_('for {course_display_name}').format(course_display_name=course_overview.display_name_with_default)} + </span> + </span> % endif % if show_courseware_link or course_overview.has_social_sharing_url() or course_overview.has_marketing_url(): diff --git a/themes/edx.org/lms/templates/dashboard.html b/themes/edx.org/lms/templates/dashboard.html index e05515c7f599d58558a5f6408b933e1446f6dff3..63a54c5a803c6e6650871664588893e6c4fe2e1c 100644 --- a/themes/edx.org/lms/templates/dashboard.html +++ b/themes/edx.org/lms/templates/dashboard.html @@ -190,7 +190,7 @@ from student.models import CourseEnrollment show_email_settings = (enrollment.course_id in show_email_settings_for) session_id = enrollment.course_id - show_courseware_link = (session_id in show_courseware_links_for) + show_courseware_link = show_courseware_links_for.get(session_id, False) cert_status = cert_statuses.get(session_id) can_refund_entitlement = entitlement and entitlement.is_entitlement_refundable() can_unenroll = (not cert_status) or cert_status.get('can_unenroll') if not unfulfilled_entitlement else False