diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-05-13 10:07:31 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-05-13 10:07:31 +0200 |
commit | 17f8b25fe52913a92c0a9cf26c1d8ec1dc3472b9 (patch) | |
tree | a534ad2b088bd3c3565396c6c81e69378183d108 | |
parent | 6034ba2537368f7da0569e7614bd2c7f110457b1 (diff) |
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.
-rw-r--r-- | ogcp/views.py | 10 |
1 files 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, |