diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-08-30 17:04:25 +0200 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-08-31 15:57:52 +0200 |
commit | 4ba34ca594736940f3778f527214cacf0421059e (patch) | |
tree | 848da6778e0865b405ce0b7c8374c09fbbe72353 | |
parent | 17f91229d6792aa182d1a67adf323488bf2d784d (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.
-rw-r--r-- | ogcp/forms/action_forms.py | 1 | ||||
-rw-r--r-- | ogcp/views.py | 9 |
2 files changed, 8 insertions, 2 deletions
diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py index a7bb5b4..dcf4965 100644 --- a/ogcp/forms/action_forms.py +++ b/ogcp/forms/action_forms.py @@ -18,6 +18,7 @@ from flask_babel import _ class GenericForm(FlaskForm): ips = HiddenField() ids = HiddenField() + server = HiddenField() submit = SubmitField(label=_l('Submit')) 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')) |