summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-30 17:04:25 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-09-27 09:48:36 +0200
commit083caf00c61f9273522bb19a0cd89b83606808ec (patch)
tree015e9fc2ed0c7dfd7bd847da649fff70a803917e /ogcp/views.py
parent70eb7389bb5d9015196938d9a589c7d406f29364 (diff)
Adapt Delete image to work with several ogServers
This commit makes Delete image view to use ogServer field from imagesForm to send the deletion request to the correct ogServer.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r--ogcp/views.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index c2a40b8..0511d3c 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1661,19 +1661,24 @@ def action_image_delete():
return redirect(url_for('images'))
id = ids.pop()
payload = {'image': id}
- r = g.server.post('/image/delete', payload)
+ server = get_server_from_ip_port(form.server.data)
+ r = server.post('/image/delete', payload)
if r.status_code != requests.codes.ok:
flash(_('OgServer replied with a non ok status code'), category='error')
else:
flash(_('Image deletion request sent successfully'), category='info')
return redirect(url_for('images'))
else:
- images = [(name, imgid) for name, imgid in request.args.to_dict().items() if name != "csrf_token"]
+ params = request.args.to_dict()
+ images = [(name, imgid) for name, imgid in params.items()
+ if name != 'csrf_token' and name != 'image-server']
if not validate_elements(images, max_len=1):
return redirect(url_for('images'))
image_name, image_id = images[0]
+ server = get_server_from_ip_port(params['image-server'])
responses = multi_request('get', '/images')
form.ids.data = image_id
+ form.server.data = params['image-server']
if not validate_elements(images, max_len=1):
flash(_('Please select one image to delete'), category='error')
return redirect(url_for('images'))