diff --git a/common/djangoapps/student/tests/test_views.py b/common/djangoapps/student/tests/test_views.py index ffa5c6b089..20b00120ee 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 4414178040..ab0d3aca4b 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 1fc45e6c1e..22f5e529d8 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 680bd640c9..1b16d0ba33 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_ % elif not is_course_blocked: - ${_('View Course')} @@ -202,6 +202,14 @@ from util.course import get_link_for_about_page, get_encoded_course_sharing_utm_ % endif % endif + % elif hasattr(show_courseware_link, 'user_message'): + + ${show_courseware_link.user_message} + +  ${_('for {course_display_name}').format(course_display_name=course_overview.display_name_with_default)} + + % 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 e05515c7f5..63a54c5a80 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