summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2022-02-23 10:07:45 +0100
committerJose M. Guisado <jguisado@soleta.eu>2022-02-23 10:07:45 +0100
commit1d68e2619a74d7d8b2bd8faefbf01b9794f3a2f7 (patch)
tree30390ae5d81e77eefeb37c2263afa02054949949 /ogcp
parent5de191964aa8044863c48309fac60705c55fcdde (diff)
Show error messages in action_image_restore
If something goes wrong, the application shows an error message after redirecting to the commands view. Do not show blank pages with plain text error codes.
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/views.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 99e7fa1..c60bd08 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -411,7 +411,8 @@ def action_image_restore():
images_list = r.json()['images']
image = search_image(images_list, int(image_id))
if not image:
- return make_response("400 Bad Request", 400)
+ flash(_(f'Image to restore was not found'), category='error')
+ return redirect(url_for('commands'))
payload = {'disk': disk,
'partition': partition,
@@ -423,8 +424,10 @@ def action_image_restore():
'id': str(image['id'])}
g.server.post('/image/restore', payload)
if r.status_code == requests.codes.ok:
- return redirect(url_for('commands'))
- return make_response("400 Bad Request", 400)
+ flash(_(f'Image restore command sent sucessfully'), category='info')
+ else:
+ flash(_(f'There was a problem sending the image restore command'), category='error')
+ return redirect(url_for('commands'))
else:
ips = parse_elements(request.args.to_dict())
if not validate_elements(ips):