From b44114d1717d98c312ab45d15e3d56234b4c10d6 Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Wed, 21 Mar 2018 14:12:31 +1030 Subject: [PATCH 1/5] Shows the account activation message in the sidebar and removes the DISPLAY_ACCOUNT_ACTIVATION_MESSAGE_ON_SIDEBAR flag, since this feature is now always on. Marks the top banner as deprecated. --- .../student/tests/test_activate_account.py | 28 ------------------- common/djangoapps/student/views/dashboard.py | 17 ++--------- lms/envs/common.py | 3 -- .../registration/activate_account_notice.html | 28 ------------------- 4 files changed, 2 insertions(+), 74 deletions(-) delete mode 100644 lms/templates/registration/activate_account_notice.html diff --git a/common/djangoapps/student/tests/test_activate_account.py b/common/djangoapps/student/tests/test_activate_account.py index 30cd2e1a7a..62430bf432 100644 --- a/common/djangoapps/student/tests/test_activate_account.py +++ b/common/djangoapps/student/tests/test_activate_account.py @@ -112,7 +112,6 @@ class TestActivateAccount(TestCase): def test_activation_without_keys(self, mock_segment_identify): self.assert_no_tracking(mock_segment_identify) - @override_settings(FEATURES=dict(settings.FEATURES, DISPLAY_ACCOUNT_ACTIVATION_MESSAGE_ON_SIDEBAR=True)) def test_account_activation_message(self): """ Verify that account correct activation message is displayed. @@ -149,33 +148,6 @@ class TestActivateAccount(TestCase): response = self.client.get(reverse('dashboard')) self.assertNotContains(response, expected_message, html=True) - @override_settings(FEATURES=dict(settings.FEATURES, DISPLAY_ACCOUNT_ACTIVATION_MESSAGE_ON_SIDEBAR=False)) - def test_account_activation_message_disabled(self): - """ - Verify that old account activation message is displayed when - DISPLAY_ACCOUNT_ACTIVATION_MESSAGE_ON_SIDEBAR is disabled. - """ - # Log in with test user. - self.login() - expected_message = render_to_string( - 'registration/activate_account_notice.html', - {'email': self.user.email} - ) - - response = self.client.get(reverse('dashboard')) - self.assertContains(response, expected_message, html=True) - - # Now make sure account activation message goes away when user activated the account - self.user.is_active = True - self.user.save() - self.login() - expected_message = render_to_string( - 'registration/activate_account_notice.html', - {'email': self.user.email} - ) - response = self.client.get(reverse('dashboard')) - self.assertNotContains(response, expected_message, html=True) - def test_account_activation_notification_on_logistration(self): """ Verify that logistration page displays success/error/info messages diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py index 4b81553c6f..f9d44c84b3 100644 --- a/common/djangoapps/student/views/dashboard.py +++ b/common/djangoapps/student/views/dashboard.py @@ -599,16 +599,9 @@ def student_dashboard(request): ) course_optouts = Optout.objects.filter(user=user).values_list('course_id', flat=True) + # Display activation message in sidebar sidebar_account_activation_message = '' - banner_account_activation_message = '' - display_account_activation_message_on_sidebar = configuration_helpers.get_value( - 'DISPLAY_ACCOUNT_ACTIVATION_MESSAGE_ON_SIDEBAR', - settings.FEATURES.get('DISPLAY_ACCOUNT_ACTIVATION_MESSAGE_ON_SIDEBAR', False) - ) - - # Display activation message in sidebar if DISPLAY_ACCOUNT_ACTIVATION_MESSAGE_ON_SIDEBAR - # flag is active. Otherwise display existing message at the top. - if display_account_activation_message_on_sidebar and not user.is_active: + if not user.is_active: sidebar_account_activation_message = render_to_string( 'registration/account_activation_sidebar_notice.html', { @@ -617,11 +610,6 @@ def student_dashboard(request): 'activation_email_support_link': activation_email_support_link } ) - elif not user.is_active: - banner_account_activation_message = render_to_string( - 'registration/activate_account_notice.html', - {'email': user.email} - ) enterprise_message = get_dashboard_consent_notification(request, user, course_enrollments) @@ -789,7 +777,6 @@ def student_dashboard(request): 'course_entitlement_available_sessions': course_entitlement_available_sessions, 'unfulfilled_entitlement_pseudo_sessions': unfulfilled_entitlement_pseudo_sessions, 'course_optouts': course_optouts, - 'banner_account_activation_message': banner_account_activation_message, 'sidebar_account_activation_message': sidebar_account_activation_message, 'staff_access': staff_access, 'errored_courses': errored_courses, diff --git a/lms/envs/common.py b/lms/envs/common.py index 4cf56e2341..b45fbc4dca 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -376,9 +376,6 @@ FEATURES = { # See LEARNER-493 'ENABLE_ONE_CLICK_PROGRAM_PURCHASE': False, - # Whether to display account activation notification on dashboard. - 'DISPLAY_ACCOUNT_ACTIVATION_MESSAGE_ON_SIDEBAR': False, - # Allow users to change their email address. 'ALLOW_EMAIL_ADDRESS_CHANGE': True, diff --git a/lms/templates/registration/activate_account_notice.html b/lms/templates/registration/activate_account_notice.html deleted file mode 100644 index 80b809943e..0000000000 --- a/lms/templates/registration/activate_account_notice.html +++ /dev/null @@ -1,28 +0,0 @@ -<%page expression_filter="h"/> -<%! -from django.utils.translation import ugettext as _ -from openedx.core.djangolib.markup import HTML, Text -%> -
-
-
-

${_("You're almost there!")}

-
-

${Text(_( - "There's just one more step: Before you " - "enroll in a course, you need to activate " - "your account. We've sent an email message to " - "{email_start}{email}{email_end} with " - "instructions for activating your account. If " - "you don't receive this message, check your " - "spam folder." - )).format( - email_start=HTML(""), - email_end=HTML(""), - email=email, - )} -

-
-
-
-
\ No newline at end of file From 22ee400b158cb1b45caa47e9d3275e42aab66686 Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Wed, 21 Mar 2018 14:27:50 +1030 Subject: [PATCH 2/5] 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. --- common/djangoapps/student/tests/test_views.py | 22 +++++++++++++++++++ common/djangoapps/student/views/dashboard.py | 5 +++++ lms/envs/common.py | 3 +++ lms/templates/dashboard.html | 3 ++- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/common/djangoapps/student/tests/test_views.py b/common/djangoapps/student/tests/test_views.py index ed841fd031..186abf0a16 100644 --- a/common/djangoapps/student/tests/test_views.py +++ b/common/djangoapps/student/tests/test_views.py @@ -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()) diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py index f9d44c84b3..fcd144159f 100644 --- a/common/djangoapps/student/views/dashboard.py +++ b/common/djangoapps/student/views/dashboard.py @@ -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): diff --git a/lms/envs/common.py b/lms/envs/common.py index b45fbc4dca..a67f57d174 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -137,6 +137,9 @@ FEATURES = { # Can be turned off if course lists need to be hidden. Effects views and templates. '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 'RESTRICT_ENROLL_BY_REG_METHOD': False, diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html index 8a330f3ec7..2c9c4ca994 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -120,7 +120,7 @@ from student.models import CourseEnrollment
- + % if display_dashboard_courses:
<%include file="learner_dashboard/_dashboard_navigation_courses.html"/> @@ -222,6 +222,7 @@ from student.models import CourseEnrollment % endif
+ % endif
%if sidebar_account_activation_message: