Skip to content

Commit

Permalink
comment out section instead of changing form
Browse files Browse the repository at this point in the history
  • Loading branch information
claire-peters committed Dec 20, 2023
1 parent cdf30c6 commit 5d2192e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
12 changes: 6 additions & 6 deletions coldfront/core/allocation/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ class AllocationChangeForm(forms.Form):
for choice in ALLOCATION_CHANGE_REQUEST_EXTENSION_DAYS:
EXTENSION_CHOICES.append((choice, "{} days".format(choice)))

# end_date_extension = forms.TypedChoiceField(
# label='Request End Date Extension',
# choices = EXTENSION_CHOICES,
# coerce=int,
# required=False,
# empty_value=0,)
end_date_extension = forms.TypedChoiceField(
label='Request End Date Extension',
choices = EXTENSION_CHOICES,
coerce=int,
required=False,
empty_value=0,)
justification = forms.CharField(
label='Justification for Changes',
widget=forms.Textarea,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ <h3><i class="fas fa-list" aria-hidden="true"></i> Allocation Information</h3>
<th scope="row" class="text-nowrap">Start Date:</th>
<td>{{ allocation.start_date }}</td>
</tr>
{% comment %}
<tr>
<th scope="row" class="text-nowrap">End Date:</th>
<td>
Expand All @@ -68,6 +69,8 @@ <h3><i class="fas fa-list" aria-hidden="true"></i> Allocation Information</h3>
</td>
</tr>
{% endif %}
{% endcomment %}

<tr>
<th scope="row" class="text-nowrap">Description:</th>
<td>{{allocation.description|default_if_none:""}}</td>
Expand Down
38 changes: 19 additions & 19 deletions coldfront/core/allocation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1705,14 +1705,14 @@ def get(self, request, *args, **kwargs):
allocation_change_form = AllocationChangeForm(
initial={
'justification': allocation_change_obj.justification,
# 'end_date_extension': allocation_change_obj.end_date_extension,
'end_date_extension': allocation_change_obj.end_date_extension,
}
)
allocation_change_form.fields['justification'].disabled = True
# if allocation_change_obj.status.name != 'Pending':
# allocation_change_form.fields['end_date_extension'].disabled = True
# if not self.request.user.is_staff and not self.request.user.is_superuser:
# allocation_change_form.fields['end_date_extension'].disabled = True
if allocation_change_obj.status.name != 'Pending':
allocation_change_form.fields['end_date_extension'].disabled = True
if not self.request.user.is_staff and not self.request.user.is_superuser:
allocation_change_form.fields['end_date_extension'].disabled = True

note_form = AllocationChangeNoteForm(
initial={'notes': allocation_change_obj.notes}
Expand Down Expand Up @@ -1741,7 +1741,7 @@ def post(self, request, *args, **kwargs):
request.POST,
initial={
'justification': alloc_change_obj.justification,
# 'end_date_extension': alloc_change_obj.end_date_extension,
'end_date_extension': alloc_change_obj.end_date_extension,
},
)
allocation_change_form.fields['justification'].required = False
Expand Down Expand Up @@ -1810,14 +1810,14 @@ def post(self, request, *args, **kwargs):
return self.redirect_to_detail(pk)

form_data = allocation_change_form.cleaned_data
# end_date_extension = form_data.get('end_date_extension')
end_date_extension = form_data.get('end_date_extension')

if not attrs_to_change:# and end_date_extension == 0:
if not attrs_to_change and end_date_extension == 0:
messages.error(request, 'You must make a change to the allocation.')
return self.redirect_to_detail(pk)

# if end_date_extension != alloc_change_obj.end_date_extension:
# alloc_change_obj.end_date_extension = end_date_extension
if end_date_extension != alloc_change_obj.end_date_extension:
alloc_change_obj.end_date_extension = end_date_extension

if attrs_to_change:
for entry in formset:
Expand All @@ -1838,11 +1838,11 @@ def post(self, request, *args, **kwargs):
)
alloc_change_obj.status = status_approved_obj

# if alloc_change_obj.end_date_extension > 0:
# rdelta = relativedelta(days=ALLOCATION_DEFAULT_ALLOCATION_LENGTH)
# new_end_date = alloc_change_obj.allocation.end_date + rdelta
# alloc_change_obj.allocation.end_date = new_end_date
# alloc_change_obj.allocation.save()
if alloc_change_obj.end_date_extension > 0:
rdelta = relativedelta(days=ALLOCATION_DEFAULT_ALLOCATION_LENGTH)
new_end_date = alloc_change_obj.allocation.end_date + rdelta
alloc_change_obj.allocation.end_date = new_end_date
alloc_change_obj.allocation.save()

if attrs_to_change:
attr_changes = (
Expand Down Expand Up @@ -2013,8 +2013,8 @@ def post(self, request, *args, **kwargs):

form_data = form.cleaned_data

# if form_data.get('end_date_extension') != 0:
# change_requested = True
if form_data.get('end_date_extension') != 0:
change_requested = True

# if requested resource is on NESE, add to vars
nese = bool(allocation_obj.resources.filter(name__contains="nesetape"))
Expand All @@ -2041,13 +2041,13 @@ def post(self, request, *args, **kwargs):
messages.error(request, 'You must request a change.')
return HttpResponseRedirect(reverse('allocation-change', kwargs={'pk': pk}))

# end_date_extension = form_data.get('end_date_extension')
end_date_extension = form_data.get('end_date_extension')
justification = form_data.get('justification')
change_request_status = AllocationChangeStatusChoice.objects.get(name='Pending')

allocation_change_request_obj = AllocationChangeRequest.objects.create(
allocation=allocation_obj,
# end_date_extension=end_date_extension,
end_date_extension=end_date_extension,
justification=justification,
status=change_request_status,
)
Expand Down

0 comments on commit 5d2192e

Please sign in to comment.