From a2f476a3a13dcadf0306ee59facf2e83f4828c9b Mon Sep 17 00:00:00 2001 From: Dennis Jen Date: Fri, 1 Jul 2016 09:35:04 -0400 Subject: [PATCH] Disabling the learner lens still enables navigating to it. --- .../courses/tests/test_views/test_learners.py | 4 ++++ analytics_dashboard/courses/views/__init__.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/analytics_dashboard/courses/tests/test_views/test_learners.py b/analytics_dashboard/courses/tests/test_views/test_learners.py index e0f6adbab..1aa34de28 100644 --- a/analytics_dashboard/courses/tests/test_views/test_learners.py +++ b/analytics_dashboard/courses/tests/test_views/test_learners.py @@ -79,6 +79,10 @@ def test_success(self): }) self.assertNotContains(response, self.TABLE_ERROR_TEXT) + def test_success_if_hidden(self): + self.toggle_switch('enable_learner_analytics', False) + self.test_success() + @data(Timeout, ConnectionError, ValueError) def test_data_api_error(self, RequestExceptionClass): learners_payload = {'should_not': 'return this value'} diff --git a/analytics_dashboard/courses/views/__init__.py b/analytics_dashboard/courses/views/__init__.py index e9a86efb1..df87069c4 100644 --- a/analytics_dashboard/courses/views/__init__.py +++ b/analytics_dashboard/courses/views/__init__.py @@ -368,8 +368,10 @@ def get_context_data(self, **kwargs): # Get the active primary item and remove it from the list primary_nav_item = None if self.active_primary_nav_item: - primary_nav_item = [i for i in primary_nav_items if i['name'] == self.active_primary_nav_item][0] - primary_nav_items.remove(primary_nav_item) + navs = [i for i in primary_nav_items if i['name'] == self.active_primary_nav_item] + if navs: + primary_nav_item = navs[0] + primary_nav_items.remove(primary_nav_item) context.update({ 'primary_nav_item': primary_nav_item,