Return server groups visible to the current user. Includes groups owned by the user plus groups containing shared servers (Server.shared=True, visible to all authenticated users). The Administrator role does not grant visibility into other users' private groups — admins see the sam
()
| 93 | |
| 94 | |
| 95 | def get_server_groups_for_user(): |
| 96 | """Return server groups visible to the current user. |
| 97 | |
| 98 | Includes groups owned by the user plus groups containing shared |
| 99 | servers (Server.shared=True, visible to all authenticated users). |
| 100 | |
| 101 | The Administrator role does not grant visibility into other |
| 102 | users' private groups — admins see the same set as a regular |
| 103 | user with the same ownership and sharing configuration. |
| 104 | """ |
| 105 | if not config.SERVER_MODE: |
| 106 | return ServerGroup.query.filter_by( |
| 107 | user_id=current_user.id |
| 108 | ).all() |
| 109 | |
| 110 | return ServerGroup.query.filter( |
| 111 | or_( |
| 112 | ServerGroup.user_id == current_user.id, |
| 113 | ServerGroup.id.in_( |
| 114 | db.session.query(Server.servergroup_id).filter( |
| 115 | Server.shared |
| 116 | ) |
| 117 | ) |
| 118 | ) |
| 119 | ).all() |
| 120 | |
| 121 | |
| 122 | def get_user_server_query(): |
no test coverage detected