From 04fe9e836746144a597d270db16142046f1b69b3 Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Fri, 12 Jan 2024 12:41:12 +0100 Subject: views: Make session form easier to understand Show a more detailed description of each choice Display an error and redirect the user if an empty list of os's was received. Post does not work with an empty list --- ogcp/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ogcp') diff --git a/ogcp/views.py b/ogcp/views.py index c414af3..c00098f 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -838,9 +838,14 @@ def action_session(): form.ips.data = ' '.join(ips) r = server.get('/session', payload={'client': list(ips)}) sessions = r.json()['sessions'] + if not sessions: + flash(_('ogServer returned an empty session list'), + category='error') + return redirect(url_for('commands')) + for os in sessions: choice = (f"{os['disk']} {os['partition']}", - f"{os['name']} ({os['disk']},{os['partition']})") + f"OS: {os['name']} (Disk:{os['disk']}, Partition:{os['partition']})") form.os.choices.append(choice) scopes, clients = get_scopes(set(ips)) selected_clients = list(get_selected_clients(scopes['scope']).items()) -- cgit v1.2.3-18-g5258