From 1b54590dcb461d42475fd7095eafc665eb7b073f Mon Sep 17 00:00:00 2001 From: index-git Date: Thu, 18 Jan 2024 14:56:44 +0100 Subject: [PATCH] Fix user role in delete_user_roles data migration --- src/layman/upgrade/upgrade_v1_23.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/layman/upgrade/upgrade_v1_23.py b/src/layman/upgrade/upgrade_v1_23.py index 7078138e0..f59f438bc 100644 --- a/src/layman/upgrade/upgrade_v1_23.py +++ b/src/layman/upgrade/upgrade_v1_23.py @@ -136,8 +136,9 @@ def delete_user_roles(): gs_rest_roles_service = urljoin(GS_REST, f'security/roles/service/{role_service}/') for user in users.get_usernames(): - logger.info(f' Delete user {user}') - for role in [f'USER_{user}', settings.LAYMAN_GS_ROLE]: + user_role = f'USER_{user.upper()}' + logger.info(f' Delete user {user} with role {user_role}') + for role in [user_role, settings.LAYMAN_GS_ROLE]: r_url = urljoin(gs_rest_roles_service, f'role/{role}/user/{user}/') response = requests.delete( r_url, @@ -150,7 +151,7 @@ def delete_user_roles(): response.raise_for_status() response = requests.delete( - urljoin(gs_rest_roles_service, 'role/' + role), + urljoin(gs_rest_roles_service, 'role/' + user_role), headers=gs_util.headers_json, auth=settings.LAYMAN_GS_AUTH, timeout=GS_REST_TIMEOUT,