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.
This commit is contained in:
Jillian Vogel
2018-03-21 14:27:50 +10:30
parent b44114d171
commit 22ee400b15
4 changed files with 32 additions and 1 deletions

View File

@@ -264,6 +264,11 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
'DASHBOARD_TWITTER': True,
},
}
MOCK_SETTINGS_HIDE_COURSES = {
'FEATURES': {
'HIDE_DASHBOARD_COURSES_UNTIL_ACTIVATED': True,
}
}
def setUp(self):
"""
@@ -611,6 +616,23 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
response = self.client.get(self.path)
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
def _remove_whitespace_from_html_string(html):
return ''.join(html.split())

View File

@@ -559,6 +559,10 @@ def student_dashboard(request):
activation_email_support_link = configuration_helpers.get_value(
'ACTIVATION_EMAIL_SUPPORT_LINK', settings.ACTIVATION_EMAIL_SUPPORT_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
site_org_whitelist, site_org_blacklist = get_org_black_and_whitelist_for_site()
@@ -806,6 +810,7 @@ def student_dashboard(request):
'disable_courseware_js': True,
'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),
}
if ecommerce_service.is_enabled(request.user):