Skip to content

Commit a4053af

Browse files
authored
Merge pull request #430 from ubccr/allocation-change-error-fix
Allocation change error fix
2 parents 5ea5784 + 48bd502 commit a4053af

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

coldfront/core/allocation/views.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,6 +2204,7 @@ def post(self, request, *args, **kwargs):
22042204
allocation_attributes_to_change = self.get_allocation_attributes_to_change(
22052205
allocation_obj)
22062206

2207+
# TODO: this logic is a mess. Needs to be cleaned up
22072208
if allocation_attributes_to_change:
22082209
formset = formset_factory(self.formset_class, max_num=len(
22092210
allocation_attributes_to_change))
@@ -2213,7 +2214,8 @@ def post(self, request, *args, **kwargs):
22132214
if form.is_valid() and formset.is_valid():
22142215
form_data = form.cleaned_data
22152216

2216-
if form_data.get('end_date_extension') != 0: change_requested = True
2217+
if form_data.get('end_date_extension') != 0:
2218+
change_requested = True
22172219

22182220
for entry in formset:
22192221
formset_data = entry.cleaned_data
@@ -2307,30 +2309,29 @@ def post(self, request, *args, **kwargs):
23072309
messages.success(
23082310
request, 'Allocation change request successfully submitted.')
23092311

2310-
pi_name = '{} {} ({})'.format(allocation_obj.project.pi.first_name,
2311-
allocation_obj.project.pi.last_name, allocation_obj.project.pi.username)
2312-
resource_name = allocation_obj.get_parent_resource
2313-
domain_url = get_domain_url(self.request)
2314-
url = '{}{}'.format(domain_url, reverse('allocation-change-list'))
2312+
pi_name = '{} {} ({})'.format(allocation_obj.project.pi.first_name,
2313+
allocation_obj.project.pi.last_name, allocation_obj.project.pi.username)
2314+
resource_name = allocation_obj.get_parent_resource
2315+
domain_url = get_domain_url(self.request)
2316+
url = '{}{}'.format(domain_url, reverse('allocation-change-list'))
23152317

2316-
if EMAIL_ENABLED:
2317-
template_context = {
2318-
'pi': pi_name,
2319-
'resource': resource_name,
2320-
'url': url
2321-
}
2318+
if EMAIL_ENABLED:
2319+
template_context = {
2320+
'pi': pi_name,
2321+
'resource': resource_name,
2322+
'url': url
2323+
}
23222324

2323-
send_email_template(
2324-
'New Allocation Change Request: {} - {}'.format(
2325-
pi_name, resource_name),
2326-
'email/new_allocation_change_request.txt',
2327-
template_context,
2328-
EMAIL_SENDER,
2329-
[EMAIL_TICKET_SYSTEM_ADDRESS, ]
2330-
)
2325+
send_email_template(
2326+
'New Allocation Change Request: {} - {}'.format(
2327+
pi_name, resource_name),
2328+
'email/new_allocation_change_request.txt',
2329+
template_context,
2330+
EMAIL_SENDER,
2331+
[EMAIL_TICKET_SYSTEM_ADDRESS, ]
2332+
)
23312333

23322334
return HttpResponseRedirect(reverse('allocation-detail', kwargs={'pk': pk}))
2333-
23342335
else:
23352336
messages.error(request, 'You must request a change.')
23362337
return HttpResponseRedirect(reverse('allocation-change', kwargs={'pk': pk}))

coldfront/core/utils/management/commands/load_test_data.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def handle(self, *args, **options):
273273
status=AllocationStatusChoice.objects.get(name='Active'),
274274
start_date=start_date,
275275
end_date=end_date,
276+
is_changeable=True,
276277
justification='I need access to my nodes.'
277278
)
278279

@@ -305,6 +306,7 @@ def handle(self, *args, **options):
305306
status=AllocationStatusChoice.objects.get(name='Active'),
306307
start_date=start_date,
307308
end_date=datetime.datetime.now() + relativedelta(days=10),
309+
is_changeable=True,
308310
justification='I need access to university cluster.'
309311
)
310312

@@ -359,6 +361,7 @@ def handle(self, *args, **options):
359361
start_date=start_date,
360362
end_date=end_date,
361363
quantity=10,
364+
is_changeable=True,
362365
justification='I need extra storage.'
363366
)
364367

@@ -378,6 +381,7 @@ def handle(self, *args, **options):
378381
status=AllocationStatusChoice.objects.get(name='Active'),
379382
start_date=start_date,
380383
end_date=end_date,
384+
is_changeable=True,
381385
justification='I need compute time on metered cluster.'
382386
)
383387
allocation_obj.resources.add(
@@ -484,6 +488,7 @@ def handle(self, *args, **options):
484488
status=AllocationStatusChoice.objects.get(name='Active'),
485489
start_date=start_date,
486490
end_date=end_date,
491+
is_changeable=True,
487492
justification='Need to host my own site.'
488493
)
489494

@@ -520,6 +525,7 @@ def handle(self, *args, **options):
520525
status=AllocationStatusChoice.objects.get(name='Active'),
521526
start_date=start_date,
522527
end_date=end_date,
528+
is_changeable=True,
523529
justification='Need extra storage for webserver.'
524530
)
525531

0 commit comments

Comments
 (0)