From ee8632c701d4a3448090f770a2e59af597272904 Mon Sep 17 00:00:00 2001 From: "marcel.kocisek" Date: Thu, 12 Dec 2024 15:34:22 +0100 Subject: [PATCH] Do not count admins --- server/mergin/sync/workspace.py | 6 +----- server/mergin/tests/test_workspace.py | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/server/mergin/sync/workspace.py b/server/mergin/sync/workspace.py index 3fd506df..826445f9 100644 --- a/server/mergin/sync/workspace.py +++ b/server/mergin/sync/workspace.py @@ -354,13 +354,9 @@ def project_access(self, project: Project) -> List[ProjectAccessDetail]: def server_editors_count(self) -> int: if Configuration.GLOBAL_ADMIN or Configuration.GLOBAL_WRITE: - return User.query.filter( - is_(User.username.ilike("deleted_%"), False) | User.active - ).count() - if Configuration.GLOBAL_READ: return User.query.filter( is_(User.username.ilike("deleted_%"), False) | User.active, - User.is_admin.is_(True), + User.is_admin.is_(False), ).count() return ( diff --git a/server/mergin/tests/test_workspace.py b/server/mergin/tests/test_workspace.py index 2aafc268..47c62981 100644 --- a/server/mergin/tests/test_workspace.py +++ b/server/mergin/tests/test_workspace.py @@ -45,7 +45,7 @@ def test_workspace_implementation(client): Configuration.GLOBAL_WRITE = True assert ws.user_has_permissions(user, "write") assert ws.user_has_permissions(user, "read") - assert handler.server_editors_count() == 2 + assert handler.server_editors_count() == 1 assert not ws.user_has_permissions(user, "admin") assert not ws.user_has_permissions(user, "owner") @@ -76,7 +76,7 @@ def test_workspace_implementation(client): project.removed_by = user.id db.session.commit() assert ws.disk_usage() == default_project_usage - assert handler.server_editors_count() == 2 + assert handler.server_editors_count() == 1 current_time = datetime.datetime.now(datetime.timezone.utc) latest_version.created = datetime.datetime.combine(