Skip to content

Commit

Permalink
ubccr#294: Allocation change request update form complete
Browse files Browse the repository at this point in the history
  • Loading branch information
brisco17 committed Dec 22, 2021
1 parent 3754bac commit a94ccc1
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 97 deletions.
22 changes: 21 additions & 1 deletion coldfront/core/allocation/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,29 @@ def clean(self):
allocation_attribute.clean()


class AllocationAttributeUpdateForm(forms.Form):
change_pk = forms.IntegerField(required=False, disabled=True)
attribute_pk = forms.IntegerField(required=False, disabled=True)
name = forms.CharField(max_length=150, required=False, disabled=True)
value = forms.CharField(max_length=150, required=False, disabled=True)
new_value = forms.CharField(max_length=150, required=False, disabled=False)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['change_pk'].widget = forms.HiddenInput()
self.fields['attribute_pk'].widget = forms.HiddenInput()

def clean(self):
cleaned_data = super().clean()
allocation_attribute = AllocationAttribute.objects.get(pk=cleaned_data.get('attribute_pk'))

allocation_attribute.value = cleaned_data.get('new_value')
allocation_attribute.clean()


class AllocationChangeForm(forms.Form):
EXTENSION_CHOICES = [
(0, "----")
(0, "No Extension")
]
for choice in ALLOCATION_CHANGE_REQUEST_EXTENSION_DAYS:
EXTENSION_CHOICES.append((choice, "{} days".format(choice)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h3 class="d-inline"><i class="fas fa-info-circle" aria-hidden="true"></i> Alloc
<td>{{form.value.value}}</td>
<td>
{{form.new_value}}
<a href="" class="float-right">
<a href="{% url 'allocation-attribute-change-delete' form.change_pk.value %}" class="float-right confirm-delete">
<i class="far fa-trash-alt fa-lg"></i>
</a>
</td>
Expand Down Expand Up @@ -206,4 +206,10 @@ <h3 class="d-inline"><i class="fas fa-info-circle" aria-hidden="true"></i> Actio
{% endif %}
<br>

<script>
$(document).on('click', '.confirm-delete', function(){
return confirm('Are you sure you want to delete this requested allocation attribute change?');
})
</script>
{% endblock %}

2 changes: 2 additions & 0 deletions coldfront/core/allocation/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
name='allocation-activate-change'),
path('<int:pk>/deny-change-request', allocation_views.AllocationChangeDenyView.as_view(),
name='allocation-deny-change'),
path('<int:pk>/delete-attribute-change', allocation_views.AllocationChangeDeleteAttributeView.as_view(),
name='allocation-attribute-change-delete'),
path('<int:pk>/add-users', allocation_views.AllocationAddUsersView.as_view(),
name='allocation-add-users'),
path('<int:pk>/remove-users', allocation_views.AllocationRemoveUsersView.as_view(),
Expand Down
Loading

0 comments on commit a94ccc1

Please sign in to comment.