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

Adds HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED

Site Configuration and feature flag

When set, it hides the Courses list on the Learner Dashboard page if the
learner has not yet activated their account.

(cherry picked from commit 22ee400b)
parent d585294f
No related branches found
No related tags found
No related merge requests found
...@@ -264,6 +264,11 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin, ...@@ -264,6 +264,11 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
'DASHBOARD_TWITTER': True, 'DASHBOARD_TWITTER': True,
}, },
} }
MOCK_SETTINGS_HIDE_COURSES = {
'FEATURES': {
'HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED': True,
}
}
def setUp(self): def setUp(self):
""" """
...@@ -619,6 +624,23 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin, ...@@ -619,6 +624,23 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
response = self.client.get(self.path) response = self.client.get(self.path)
self.assertEqual(pq(response.content)(self.EMAIL_SETTINGS_ELEMENT_ID).length, 0) self.assertEqual(pq(response.content)(self.EMAIL_SETTINGS_ELEMENT_ID).length, 0)
@patch.multiple('django.conf.settings', **MOCK_SETTINGS_HIDE_COURSES)
def test_hide_dashboard_courses_until_activated(self):
"""
Verify that when the HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED feature is enabled,
inactive users don't see the Courses list, but active users still do.
"""
# Ensure active users see the course list
self.assertTrue(self.user.is_active)
response = self.client.get(reverse('dashboard'))
self.assertIn('You are not enrolled in any courses yet.', response.content)
# Ensure inactive users don't see the course list
self.user.is_active = False
self.user.save()
response = self.client.get(reverse('dashboard'))
self.assertNotIn('You are not enrolled in any courses yet.', response.content)
@staticmethod @staticmethod
def _remove_whitespace_from_html_string(html): def _remove_whitespace_from_html_string(html):
return ''.join(html.split()) return ''.join(html.split())
......
...@@ -562,6 +562,10 @@ def student_dashboard(request): ...@@ -562,6 +562,10 @@ def student_dashboard(request):
activation_email_support_link = configuration_helpers.get_value( activation_email_support_link = configuration_helpers.get_value(
'ACTIVATION_EMAIL_SUPPORT_LINK', settings.ACTIVATION_EMAIL_SUPPORT_LINK 'ACTIVATION_EMAIL_SUPPORT_LINK', settings.ACTIVATION_EMAIL_SUPPORT_LINK
) or settings.SUPPORT_SITE_LINK ) or settings.SUPPORT_SITE_LINK
hide_dashboard_courses_until_activated = configuration_helpers.get_value(
'HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED',
settings.FEATURES.get('HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED', False)
)
# Get the org whitelist or the org blacklist for the current site # 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() site_org_whitelist, site_org_blacklist = get_org_black_and_whitelist_for_site()
...@@ -812,6 +816,7 @@ def student_dashboard(request): ...@@ -812,6 +816,7 @@ def student_dashboard(request):
'disable_courseware_js': True, 'disable_courseware_js': True,
'display_course_modes_on_dashboard': enable_verified_certificates and display_course_modes_on_dashboard, 'display_course_modes_on_dashboard': enable_verified_certificates and display_course_modes_on_dashboard,
'display_sidebar_on_dashboard': display_sidebar_on_dashboard, 'display_sidebar_on_dashboard': display_sidebar_on_dashboard,
'display_dashboard_courses': (user.is_active or not hide_dashboard_courses_until_activated),
} }
if ecommerce_service.is_enabled(request.user): if ecommerce_service.is_enabled(request.user):
......
...@@ -133,6 +133,9 @@ FEATURES = { ...@@ -133,6 +133,9 @@ FEATURES = {
# Can be turned off if course lists need to be hidden. Effects views and templates. # Can be turned off if course lists need to be hidden. Effects views and templates.
'COURSES_ARE_BROWSABLE': True, 'COURSES_ARE_BROWSABLE': True,
# Set to hide the courses list on the Learner Dashboard if they are not enrolled in any courses yet.
'HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED': False,
# Enables ability to restrict enrollment in specific courses by the user account login method # Enables ability to restrict enrollment in specific courses by the user account login method
'RESTRICT_ENROLL_BY_REG_METHOD': False, 'RESTRICT_ENROLL_BY_REG_METHOD': False,
......
...@@ -122,7 +122,7 @@ from student.models import CourseEnrollment ...@@ -122,7 +122,7 @@ from student.models import CourseEnrollment
<main id="main" aria-label="Content" tabindex="-1"> <main id="main" aria-label="Content" tabindex="-1">
<div class="dashboard" id="dashboard-main"> <div class="dashboard" id="dashboard-main">
% if display_dashboard_courses:
<div class="main-container"> <div class="main-container">
<div class="my-courses" id="my-courses"> <div class="my-courses" id="my-courses">
<%include file="learner_dashboard/_dashboard_navigation_courses.html"/> <%include file="learner_dashboard/_dashboard_navigation_courses.html"/>
...@@ -224,6 +224,7 @@ from student.models import CourseEnrollment ...@@ -224,6 +224,7 @@ from student.models import CourseEnrollment
% endif % endif
</div> </div>
</div> </div>
% endif
<div class="side-container"> <div class="side-container">
%if sidebar_account_activation_message: %if sidebar_account_activation_message:
<div class="sidebar-notification"> <div class="sidebar-notification">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment