diff --git a/src/documents/migrations/0019_alter_document_options.py b/src/documents/migrations/0019_alter_document_options.py index d177d6759..7de9dac93 100644 --- a/src/documents/migrations/0019_alter_document_options.py +++ b/src/documents/migrations/0019_alter_document_options.py @@ -15,7 +15,7 @@ class Migration(migrations.Migration): "ordering": ("-created",), "permissions": [ ( - "can_view_statistics", + "view_global_statistics", "Can view system statistics and object counts", ), ], diff --git a/src/documents/models.py b/src/documents/models.py index 1d3e50da7..d14914b90 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -340,7 +340,7 @@ class Document(SoftDeleteModel, ModelWithOwner): # type: ignore[django-manager- verbose_name = _("document") verbose_name_plural = _("documents") permissions = [ - ("can_view_statistics", "Can view system statistics and object counts"), + ("view_global_statistics", "Can view system statistics and object counts"), ] constraints = [ models.UniqueConstraint( diff --git a/src/documents/permissions.py b/src/documents/permissions.py index 66048c035..017969349 100644 --- a/src/documents/permissions.py +++ b/src/documents/permissions.py @@ -61,7 +61,7 @@ def has_statistics_permission(user: User | None) -> bool: return False return getattr(user, "is_superuser", False) or user.has_perm( - "documents.can_view_statistics", + "documents.view_global_statistics", ) diff --git a/src/documents/tests/test_api_bulk_edit.py b/src/documents/tests/test_api_bulk_edit.py index f783bab13..9bb59d3de 100644 --- a/src/documents/tests/test_api_bulk_edit.py +++ b/src/documents/tests/test_api_bulk_edit.py @@ -924,7 +924,7 @@ class TestBulkEditAPI(DirectoriesMixin, APITestCase): stats_user = User.objects.create(username="stats_user") stats_user.user_permissions.add( - Permission.objects.get(codename="can_view_statistics"), + Permission.objects.get(codename="view_global_statistics"), ) self.client.force_authenticate(user=stats_user) diff --git a/src/documents/tests/test_api_custom_fields.py b/src/documents/tests/test_api_custom_fields.py index c3949b943..ac7679632 100644 --- a/src/documents/tests/test_api_custom_fields.py +++ b/src/documents/tests/test_api_custom_fields.py @@ -1309,7 +1309,7 @@ class TestCustomFieldsAPI(DirectoriesMixin, APITestCase): # Test as user without access to the document non_superuser = User.objects.create_user(username="non_superuser") non_superuser.user_permissions.add( - *Permission.objects.exclude(codename="can_view_statistics"), + *Permission.objects.exclude(codename="view_global_statistics"), ) non_superuser.save() self.client.force_authenticate(user=non_superuser) diff --git a/src/documents/tests/test_api_documents.py b/src/documents/tests/test_api_documents.py index 7446214dd..38e7eb013 100644 --- a/src/documents/tests/test_api_documents.py +++ b/src/documents/tests/test_api_documents.py @@ -1318,7 +1318,7 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase): owner = User.objects.create_user("owner") stats_user = User.objects.create_user("stats-user") stats_user.user_permissions.add( - Permission.objects.get(codename="can_view_statistics"), + Permission.objects.get(codename="view_global_statistics"), ) inbox_tag = Tag.objects.create( @@ -1353,7 +1353,7 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase): owner = User.objects.create_user("owner") stats_user = User.objects.create_user("stats-user") stats_user.user_permissions.add( - Permission.objects.get(codename="can_view_statistics"), + Permission.objects.get(codename="view_global_statistics"), Permission.objects.get(codename="view_tag"), ) diff --git a/src/documents/tests/test_api_status.py b/src/documents/tests/test_api_status.py index ea81acb9b..89c9c73d3 100644 --- a/src/documents/tests/test_api_status.py +++ b/src/documents/tests/test_api_status.py @@ -96,7 +96,7 @@ class TestSystemStatus(APITestCase): def test_system_status_with_statistics_permission(self) -> None: user = User.objects.create_user(username="stats_user") user.user_permissions.add( - Permission.objects.get(codename="can_view_statistics"), + Permission.objects.get(codename="view_global_statistics"), ) self.client.force_login(user)