MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / get_server_group

Function get_server_group

web/pgadmin/utils/server_access.py:68–92  ·  view source on GitHub ↗

Fetch a server group by ID, verifying user access. Returns the group if: - Desktop mode, OR - The user owns it, OR - It contains shared servers (Server.shared=True). Returns None otherwise. The Administrator role does not grant access to other users' private groups.

(gid)

Source from the content-addressed store, hash-verified

66
67
68def get_server_group(gid):
69 """Fetch a server group by ID, verifying user access.
70
71 Returns the group if:
72 - Desktop mode, OR
73 - The user owns it, OR
74 - It contains shared servers (Server.shared=True).
75
76 Returns None otherwise. The Administrator role does not grant
77 access to other users' private groups.
78 """
79 if not config.SERVER_MODE:
80 return ServerGroup.query.filter_by(id=gid).first()
81
82 return ServerGroup.query.filter(
83 ServerGroup.id == gid,
84 or_(
85 ServerGroup.user_id == current_user.id,
86 ServerGroup.id.in_(
87 db.session.query(Server.servergroup_id).filter(
88 Server.shared
89 )
90 )
91 )
92 ).first()
93
94
95def get_server_groups_for_user():

Callers 3

propertiesMethod · 0.90
nodesMethod · 0.90
listMethod · 0.90

Calls 2

filterMethod · 0.80
firstMethod · 0.65

Tested by

no test coverage detected