From 17f8b25fe52913a92c0a9cf26c1d8ec1dc3472b9 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Mon, 13 May 2024 10:07:31 +0200 Subject: [PATCH] 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. --- ogcp/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index 77402d6..c756ac9 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -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,