From 2d3569d7992061df44aa3b905a1b43dbcdc1e8ad Mon Sep 17 00:00:00 2001 From: Claire Peters Date: Mon, 30 Oct 2023 15:44:53 -0700 Subject: [PATCH] hotfix: require nese shares to be divisible by 20 --- coldfront/core/allocation/views.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/coldfront/core/allocation/views.py b/coldfront/core/allocation/views.py index 49775cbe1..f5e2acdd6 100644 --- a/coldfront/core/allocation/views.py +++ b/coldfront/core/allocation/views.py @@ -1864,7 +1864,6 @@ def post(self, request, *args, **kwargs): if new_value != attribute_change.new_value: attribute_change.new_value = new_value attribute_change.save() - if action == 'update': message = 'Allocation change request updated!' if action == 'approve': @@ -2055,6 +2054,13 @@ def post(self, request, *args, **kwargs): formset_data = entry.cleaned_data 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 + nese = bool(allocation_obj.resources.filter(name__contains="nesetape")) + 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})) + if new_value != '': change_requested = True allocation_attribute = AllocationAttribute.objects.get(