Statistics navigation links are not tied to querysets or model instances,

don't fail when failing to access their _meta field. Fixes GitLab issue #316.
This commit is contained in:
Roberto Rosario
2016-10-20 03:46:49 -04:00
parent 5fedada0f5
commit 8250085703
2 changed files with 18 additions and 1 deletions

View File

@@ -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

View File

@@ -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)