@@ -2204,6 +2204,7 @@ def post(self, request, *args, **kwargs):
2204
2204
allocation_attributes_to_change = self .get_allocation_attributes_to_change (
2205
2205
allocation_obj )
2206
2206
2207
+ # TODO: this logic is a mess. Needs to be cleaned up
2207
2208
if allocation_attributes_to_change :
2208
2209
formset = formset_factory (self .formset_class , max_num = len (
2209
2210
allocation_attributes_to_change ))
@@ -2213,7 +2214,8 @@ def post(self, request, *args, **kwargs):
2213
2214
if form .is_valid () and formset .is_valid ():
2214
2215
form_data = form .cleaned_data
2215
2216
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
2217
2219
2218
2220
for entry in formset :
2219
2221
formset_data = entry .cleaned_data
@@ -2307,30 +2309,29 @@ def post(self, request, *args, **kwargs):
2307
2309
messages .success (
2308
2310
request , 'Allocation change request successfully submitted.' )
2309
2311
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' ))
2315
2317
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
+ }
2322
2324
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
+ )
2331
2333
2332
2334
return HttpResponseRedirect (reverse ('allocation-detail' , kwargs = {'pk' : pk }))
2333
-
2334
2335
else :
2335
2336
messages .error (request , 'You must request a change.' )
2336
2337
return HttpResponseRedirect (reverse ('allocation-change' , kwargs = {'pk' : pk }))
0 commit comments