views: report no valid partitions in image create/restore/update

Inform the user when the selected clients don't have a valid
partition type for an image create/restore/update operation and
return to the commands view.
master
Alejandro Sirgo Rica 2025-02-07 12:20:06 +01:00
parent 9bb40d267f
commit c33fe3ca77
1 changed files with 13 additions and 0 deletions

View File

@ -1124,6 +1124,10 @@ def action_image_restore():
f"{fs_type}")
)
if not form.partition.choices:
flash(_(f'No valid partition available'), category='error')
return redirect(url_for('commands'))
return render_template('actions/image_restore.html', form=form,
selected_clients=selected_clients,
scopes=scopes)
@ -2386,6 +2390,11 @@ def action_image_create():
f"| {PART_TYPE_CODES.get(part.get('code'), 'UNKNOWN')} "
f"{FS_CODES.get(part.get('filesystem'), 'UNKNOWN')}")
)
if not form.os.choices:
flash(_(f'No valid partition available'), category='error')
return redirect(url_for('commands'))
r = server.get('/client/info', payload={'client': list(ips)})
client_repo_id = r.json()['repo_id']
@ -2494,6 +2503,10 @@ def action_image_update():
part_content[partition_value] = part['image']
break
if not form.os.choices:
flash(_(f'No valid partition available'), category='error')
return redirect(url_for('commands'))
scopes, _clients = get_scopes(set(ips))
selected_clients = list(get_selected_clients(scopes['scope']).items())