Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server/mergin/sync/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,17 @@ 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),
).count()
return User.query.filter(User.active == True).count()

return (
db.session.query(ProjectUser.user_id)
.select_from(Project)
.join(ProjectUser)
.join(User, User.id == ProjectUser.user_id)
.filter(
Project.removed_at.is_(None),
ProjectUser.role != ProjectRole.READER.value,
User.active == True,
)
.group_by(ProjectUser.user_id)
.count()
Expand Down
6 changes: 6 additions & 0 deletions server/mergin/tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def test_workspace_implementation(client):
assert ws.user_has_permissions(user, "write")
assert ws.user_has_permissions(user, "read")
assert handler.server_editors_count() == 2
# inactive user should not be counted
user.active = False
db.session.commit()
assert handler.server_editors_count() == 1
user.active = True
db.session.commit()
assert not ws.user_has_permissions(user, "admin")
assert not ws.user_has_permissions(user, "owner")

Expand Down
Loading