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.
(cherry picked from commit e417c5f8c2)
This commit is contained in:
@@ -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
|
||||
@@ -641,6 +642,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())
|
||||
|
||||
@@ -566,6 +566,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()
|
||||
@@ -817,6 +820,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;
|
||||
|
||||
@@ -196,7 +196,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")}
|
||||
|
||||
Reference in New Issue
Block a user