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:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user