From a5a5ef362b0e8bb79477070ea3598b90a89b977a Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Wed, 20 Dec 2023 11:07:53 +0100 Subject: views: Limit update image to images available in assigned repository Allow to update only images that are in the repo the client is assigned to; if an image is inside a different repo, it will not appear in the 'Image' selector --- ogcp/views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index 766db70..b59f0f0 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1320,8 +1320,14 @@ def action_image_update(): form.ip.data = ' '.join(ips) server = get_server_from_clients(ips) - r = server.get('/images') - for image in r.json()['images']: + r = server.get('/client/info', payload={'client': list(ips)}) + repo_id = r.json()['repo_id'] + images = get_images_grouped_by_repos_from_server(server) + if repo_id not in images: + flash(_('Computer is assigned to a repo with no images'), + category='error') + return redirect(url_for('commands')) + for image in images[repo_id]: form.image.choices.append((image['id'], image['name'])) r = server.get('/client/setup', payload={'client': list(ips)}) -- cgit v1.2.3-18-g5258