diff --git a/mayan/apps/navigation/classes.py b/mayan/apps/navigation/classes.py index 6edbf818dc..2d45129369 100644 --- a/mayan/apps/navigation/classes.py +++ b/mayan/apps/navigation/classes.py @@ -367,7 +367,7 @@ class SourceColumn(object): # Special case for queryset items produced from # .defer() or .only() optimizations return cls._registry[source._meta.parents.items()[0][0]] - except (KeyError, IndexError): + except (AttributeError, KeyError, IndexError): return () except TypeError: # unhashable type: list diff --git a/mayan/apps/statistics/tests/test_views.py b/mayan/apps/statistics/tests/test_views.py index 133a85d5af..69daca278d 100644 --- a/mayan/apps/statistics/tests/test_views.py +++ b/mayan/apps/statistics/tests/test_views.py @@ -34,3 +34,20 @@ class StatisticsViewTestCase(GenericViewTestCase): ) self.assertEqual(response.status_code, 200) + + + def test_statistic_namespace_list_view_no_permissions(self): + self.login(username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD) + + response = self.get('statistics:namespace_list') + + self.assertEqual(response.status_code, 403) + + def test_statistic_namespace_list_view_with_permissions(self): + self.login(username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD) + + self.role.permissions.add(permission_statistics_view.stored_permission) + + response = self.get('statistics:namespace_list') + + self.assertEqual(response.status_code, 200)