Skip to content

Commit

Permalink
Groups: return API result OK when everything succeeded
Browse files Browse the repository at this point in the history
  • Loading branch information
lwesterhof committed Oct 9, 2023
1 parent 44bdfe7 commit cfd1e38
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,9 +1152,11 @@ def api_group_delete(ctx, group_name):
if status != '0':
return api.Error('policy_error', message)

if sram_group:
if config.enable_sram and sram_group:
if not sram.sram_delete_collaboration(ctx, co_identifier):
return api.Error('sram_error', 'Something went wrong deleting group "{}" in SRAM'.format(group_name))

return api.Result.ok()
except Exception:
return api.Error('error_internal', 'Something went wrong deleting group "{}". Please contact a system administrator'.format(group_name))

Expand Down Expand Up @@ -1221,6 +1223,7 @@ def api_group_user_add(ctx, username, group_name):
sram.invitation_mail_group_add_user(ctx, group_name, username.split('#')[0], co_identifier)
elif config.sram_flow == 'invitation':
sram.sram_put_collaboration_invitation(ctx, group_name, username.split('#')[0], co_identifier)

return api.Result.ok()
else:
return api.Error('policy_error', message)
Expand Down Expand Up @@ -1295,13 +1298,15 @@ def api_group_remove_user_from_group(ctx, username, group_name):
if status != '0':
return api.Error('policy_error', message)

if sram_group:
if config.enable_sram and sram_group:
uid = sram.sram_get_uid(ctx, co_identifier, username)
if uid == '':
return api.Error('sram_error', 'Something went wrong getting the unique user id for user {} from SRAM. Please contact a system administrator.'.format(username))
else:
if not sram.sram_delete_collaboration_membership(ctx, co_identifier, uid):
return api.Error('sram_error', 'Something went wrong removing {} from group "{}" in SRAM'.format(username, group_name))

return api.Result.ok()
except Exception:
return api.Error('error_internal', 'Something went wrong removing {} from group "{}". Please contact a system administrator'.format(username, group_name))

Expand Down

0 comments on commit cfd1e38

Please sign in to comment.