From ff67a56b6dd2c332bc200789905618dcf7c8a287 Mon Sep 17 00:00:00 2001 From: claire-peters Date: Mon, 5 Feb 2024 14:00:58 -0500 Subject: [PATCH] address error caused by attempt to convert decimal string into integer --- coldfront/core/allocation/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/coldfront/core/allocation/views.py b/coldfront/core/allocation/views.py index 3be2aa744..c3ca0948c 100644 --- a/coldfront/core/allocation/views.py +++ b/coldfront/core/allocation/views.py @@ -2025,7 +2025,14 @@ def post(self, request, *args, **kwargs): new_value = formset_data.get('new_value') # require nese shares to be divisible by 20 - tbs = int(new_value) if formset_data['name'] == 'Storage Quota (TB)' else False + if formset_data['name'] == 'Storage Quota (TB)': + try: + tbs = int(new_value) + except ValueError: + messages.error(request, 'Requested storage quota must be an integer.') + return HttpResponseRedirect(reverse('allocation-change', kwargs={'pk': pk})) + else: + tbs = False if nese and tbs and tbs % 20 != 0: messages.error(request, "Tier 3 quantity must be a multiple of 20.") return HttpResponseRedirect(reverse('allocation-change', kwargs={'pk': pk}))