Skip to content

Commit

Permalink
Temp setGroupForSession to edit current group
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed May 9, 2023
1 parent d53e790 commit 5e59985
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions omeroweb/webclient/webclient_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,16 @@ def updateGroup(self, group, name, permissions, description=None):
"""

temp_switch = False
if self.getEventContext().groupId == group.id:
# can't update current group
temp_switch = True
# find a group to temp switch to...
gids = [gid for gid in self.getEventContext().memberOfGroups if (gid != 0 and gid != group.id)]
if len(gids) == 0:
return ["You can't edit your current group!"]
self.setGroupForSession(gids[0])

up_gr = group._obj
up_gr.name = rstring(str(name))
up_gr.description = (
Expand All @@ -1493,6 +1503,9 @@ def updateGroup(self, group, name, permissions, description=None):
err = self.updatePermissions(group, permissions)
if err is not None:
msgs.append(err)

if temp_switch:
self.revertGroupForSession()
return msgs

def updateMyAccount(
Expand Down

0 comments on commit 5e59985

Please sign in to comment.