views: ensure only one cache partition is defined

Add validation for the case where the user defines more than one
CACHE partition in the Partition and Format form.
master
Alejandro Sirgo Rica 2024-05-13 10:07:31 +02:00
parent 6034ba2537
commit 17f8b25fe5
1 changed files with 7 additions and 3 deletions

View File

@ -642,14 +642,18 @@ def action_setup_show():
def action_setup_modify():
form = SetupForm(request.form)
if form.validate():
has_cache=False
cache_count = 0
for partition in form.partitions:
if partition.part_type.data == 'CACHE':
has_cache=True
if not has_cache:
cache_count += 1
if cache_count == 0:
flash(_(f'Missing cache partition'), category='error')
return redirect(url_for('commands'))
if cache_count > 1:
flash(_(f'More than one cache partition is not supported'), category='error')
return redirect(url_for('commands'))
ips = form.ips.data.split(' ')
payload = {'clients': ips,