Skip to content

Commit

Permalink
Merge pull request #469 from will-moore/edit_current_group
Browse files Browse the repository at this point in the history
Temp setGroupForSession to edit current group
  • Loading branch information
knabar authored May 31, 2023
2 parents 07f594d + 04e9538 commit 2c0b255
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions omeroweb/webclient/webclient_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,22 +1477,36 @@ def updateGroup(self, group, name, permissions, description=None):
"""

up_gr = group._obj
up_gr.name = rstring(str(name))
up_gr.description = (
(description != "" and description is not None)
and rstring(str(description))
or None
)
temp_switch = False
if self.getEventContext().groupId == group.id:
# we can't update the current group
# unless it's the system group (form won't include name change)
sys_id = self.getAdminService().getSecurityRoles().systemGroupId
if self.getEventContext().groupId != sys_id:
# otherwise, temp switch to allow editing of 'current' group
self.setGroupForSession(sys_id)
temp_switch = True

msgs = []
admin_serv = self.getAdminService()
admin_serv.updateGroup(up_gr)
try:
up_gr = group._obj
up_gr.name = rstring(str(name))
up_gr.description = (
(description != "" and description is not None)
and rstring(str(description))
or None
)

if str(permissions) != str(up_gr.details.getPermissions()):
err = self.updatePermissions(group, permissions)
if err is not None:
msgs.append(err)
admin_serv = self.getAdminService()
admin_serv.updateGroup(up_gr)

if str(permissions) != str(up_gr.details.getPermissions()):
err = self.updatePermissions(group, permissions)
if err is not None:
msgs.append(err)
finally:
if temp_switch:
self.revertGroupForSession()
return msgs

def updateMyAccount(
Expand Down

0 comments on commit 2c0b255

Please sign in to comment.