Allow deleting requisitions

This commit is contained in:
Mark Veidemanis 2023-05-06 11:59:30 +01:00
parent 8f92c7c840
commit e934e7b1a2
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 27 additions and 1 deletions

View File

@ -126,6 +126,11 @@ urlpatterns = [
banks.BanksRequisitionUpdate.as_view(),
name="requisition_update",
),
path(
"banks/<str:type>/req_delete/<str:pk>/",
banks.BanksRequisitionDelete.as_view(),
name="requisition_delete",
),
# Bank balances
path(
"banks/<str:type>/balances/",

View File

@ -14,6 +14,7 @@
<th>aggregator</th>
<th>payees</th>
<th>throughput</th>
<th>actions</th>
</thead>
{% for item in requisitions %}
<tr>
@ -25,6 +26,22 @@
{% endfor %}
</td>
<td>{{ item.throughput }}</td>
<td>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'requisition_delete' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete requisition {{ item.id }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
</td>
</tr>
{% endfor %}
</table>

View File

@ -1,7 +1,7 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponse
from django.urls import reverse
from mixins.views import ObjectList, ObjectUpdate
from mixins.views import ObjectDelete, ObjectList, ObjectUpdate
from rest_framework import status
from two_factor.views.mixins import OTPRequiredMixin
@ -45,6 +45,10 @@ class BanksRequisitionUpdate(LoginRequiredMixin, OTPRequiredMixin, ObjectUpdate)
return req
class BanksRequisitionDelete(LoginRequiredMixin, OTPRequiredMixin, ObjectDelete):
model = Requisition
class BanksCurrencies(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
"""
Get a list of bank accounts with their details.