Skip to content

Commit

Permalink
Do not count admins
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelGeo committed Dec 12, 2024
1 parent 3bf9a09 commit ee8632c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions server/mergin/sync/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions server/mergin/tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit ee8632c

Please sign in to comment.