Skip to content
Snippets Groups Projects
Commit e417c5f8 authored by Jillian Vogel's avatar Jillian Vogel
Browse files

Adds EMPTY_DASHBOARD_MESSAGE Site Configuration flag

When set, displays the configured text/markup under "You are not enrolled in any courses yet."

Adjusts left/right padding on .empty-dashboard-message to keep our extra message from hitting the sides.
parent 22ee400b
Branches
Tags
No related merge requests found
......@@ -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())
......
......@@ -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):
......
......@@ -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;
......
......@@ -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")}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment