Fix statistics detail view error. GitLab issue #270. @bat79a
This commit is contained in:
@@ -20,6 +20,7 @@ from .tasks import task_execute_statistic # NOQA - Force registration of task
|
||||
|
||||
class StatisticsApp(MayanAppConfig):
|
||||
name = 'statistics'
|
||||
test = True
|
||||
verbose_name = _('Statistics')
|
||||
|
||||
def ready(self):
|
||||
|
||||
0
mayan/apps/statistics/tests/__init__.py
Normal file
0
mayan/apps/statistics/tests/__init__.py
Normal file
38
mayan/apps/statistics/tests/test_views.py
Normal file
38
mayan/apps/statistics/tests/test_views.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from common.tests.test_views import GenericViewTestCase
|
||||
|
||||
from user_management.tests.literals import (
|
||||
TEST_USER_PASSWORD, TEST_USER_USERNAME
|
||||
)
|
||||
|
||||
from ..classes import Statistic
|
||||
from ..permissions import permission_statistics_view
|
||||
|
||||
|
||||
class StatisticsViewTestCase(GenericViewTestCase):
|
||||
def test_statistic_detail_view_no_permissions(self):
|
||||
self.login(username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD)
|
||||
|
||||
statistic = Statistic.get_all()[0]
|
||||
|
||||
response = self.get(
|
||||
'statistics:statistic_detail', args=(statistic.slug,)
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
def test_statistic_detail_view_with_permissions(self):
|
||||
self.login(username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD)
|
||||
|
||||
self.role.permissions.add(permission_statistics_view.stored_permission)
|
||||
|
||||
statistic = Statistic.get_all()[0]
|
||||
|
||||
response = self.get(
|
||||
'statistics:statistic_detail', args=(statistic.slug,)
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@@ -5,7 +5,7 @@ from django.http import Http404
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from common.generics import (
|
||||
ConfirmView, SingleObjectDetailView, SingleObjectListView
|
||||
ConfirmView, SimpleView, SingleObjectDetailView, SingleObjectListView
|
||||
)
|
||||
|
||||
from .classes import Statistic, StatisticNamespace
|
||||
@@ -42,7 +42,7 @@ class NamespaceDetailView(SingleObjectListView):
|
||||
return self.get_namespace().statistics
|
||||
|
||||
|
||||
class StatisticDetailView(SingleObjectDetailView):
|
||||
class StatisticDetailView(SimpleView):
|
||||
view_permission = permission_statistics_view
|
||||
|
||||
def get_extra_context(self):
|
||||
|
||||
Reference in New Issue
Block a user