diff --git a/common/djangoapps/student/tests/test_views.py b/common/djangoapps/student/tests/test_views.py index 186abf0a16a03698de1e420e0b9a672cad5d84f8..359556dde4110dcabf2a078dbb1ed73ab672afce 100644 --- a/common/djangoapps/student/tests/test_views.py +++ b/common/djangoapps/student/tests/test_views.py @@ -27,6 +27,7 @@ from milestones.tests.utils import MilestonesTestCaseMixin 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 openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration_context from pyquery import PyQuery as pq from student.cookies import get_user_info_cookie_data from student.helpers import DISABLE_UNENROLL_CERT_STATES @@ -633,6 +634,23 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin, response = self.client.get(reverse('dashboard')) self.assertNotIn('You are not enrolled in any courses yet.', response.content) + def test_show_empty_dashboard_message(self): + """ + Verify that when the EMPTY_DASHBOARD_MESSAGE feature is set, + its text is displayed in an empty courses list. + """ + empty_dashboard_message = "Check out our lovely <i>free</i> courses!" + response = self.client.get(reverse('dashboard')) + self.assertIn('You are not enrolled in any courses yet.', response.content) + self.assertNotIn(empty_dashboard_message, response.content) + + with with_site_configuration_context(configuration={ + "EMPTY_DASHBOARD_MESSAGE": empty_dashboard_message, + }): + response = self.client.get(reverse('dashboard')) + self.assertIn('You are not enrolled in any courses yet.', response.content) + self.assertIn(empty_dashboard_message, response.content) + @staticmethod def _remove_whitespace_from_html_string(html): return ''.join(html.split()) diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py index fcd144159fb0f7a60b5118f3ec70521d8dd533df..90ab25984313d88636f7a1a82c8c51b35e92d18a 100644 --- a/common/djangoapps/student/views/dashboard.py +++ b/common/djangoapps/student/views/dashboard.py @@ -563,6 +563,9 @@ def student_dashboard(request): 'HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED', settings.FEATURES.get('HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED', False) ) + empty_dashboard_message = configuration_helpers.get_value( + 'EMPTY_DASHBOARD_MESSAGE', None + ) # Get the org whitelist or the org blacklist for the current site site_org_whitelist, site_org_blacklist = get_org_black_and_whitelist_for_site() @@ -811,6 +814,7 @@ def student_dashboard(request): 'display_course_modes_on_dashboard': enable_verified_certificates and display_course_modes_on_dashboard, 'display_sidebar_on_dashboard': display_sidebar_on_dashboard, 'display_dashboard_courses': (user.is_active or not hide_dashboard_courses_until_activated), + 'empty_dashboard_message': empty_dashboard_message, } if ecommerce_service.is_enabled(request.user): diff --git a/lms/static/sass/multicourse/_dashboard.scss b/lms/static/sass/multicourse/_dashboard.scss index 63b756219561db8e3595f6982862c20fa41089b4..7de3d8b8abb20c20c55d56aed9fee06841f25fdf 100644 --- a/lms/static/sass/multicourse/_dashboard.scss +++ b/lms/static/sass/multicourse/_dashboard.scss @@ -1098,7 +1098,7 @@ .empty-dashboard-message { border: 3px solid $gray-l4; background: $gray-l6; - padding: ($baseline*2) 0; + padding: ($baseline*2) ($baseline/10); text-align: center; p { @@ -1109,7 +1109,12 @@ text-shadow: 0 1px rgba(255,255,255, 0.6); } - a { + p.custom-message { + @include font-size(14); + text-shadow: none; + } + + a.btn { background-color: theme-color('primary'); border: 1px solid theme-color('primary'); box-shadow: 0 1px 8px 0 $shadow-l1; diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html index 2c9c4ca9947235766f490df963d9a9019b3a673c..52d487ca5544e171c2df192483c8738a4a50ba0a 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -194,7 +194,9 @@ from student.models import CourseEnrollment % else: <div class="empty-dashboard-message"> <p>${_("You are not enrolled in any courses yet.")}</p> - + % if empty_dashboard_message: + <p class="custom-message">${empty_dashboard_message | n, decode.utf8}</p> + %endif % if settings.FEATURES.get('COURSES_ARE_BROWSABLE'): <a class="btn btn-primary" href="${marketing_link('COURSES')}"> ${_("Explore courses")}