Add delete button to transaction form
This commit is contained in:
parent
df0882bd88
commit
83aefe1f84
3 changed files with 9 additions and 0 deletions
|
@ -18,6 +18,7 @@
|
|||
{{ field }}
|
||||
{% endfor %}
|
||||
<div class="buttons">
|
||||
<a href="{% url 'del_transaction' transaction.id %}"><input type="button" value="Delete" /></a>
|
||||
<input type="reset" />
|
||||
<input type="submit" value="Save Transaction" />
|
||||
</div>
|
||||
|
|
|
@ -11,6 +11,7 @@ urlpatterns = [
|
|||
path(
|
||||
"transaction/<uuid>/update", views.update_transaction, name="update_transaction"
|
||||
),
|
||||
path("transaction/<uuid>/del", views.del_transaction, name="del_transaction"),
|
||||
path("transaction/<uuid>/add_invoice", views.add_invoice, name="add_invoice"),
|
||||
path(
|
||||
"transaction/<uuid>/del_invoice/<invoice_id>",
|
||||
|
|
|
@ -66,6 +66,13 @@ def update_transaction(request, uuid):
|
|||
return redirect(transaction, uuid=uuid)
|
||||
|
||||
|
||||
@login_required
|
||||
def del_transaction(request, uuid):
|
||||
_transaction = get_object_or_404(Transaction, id=uuid)
|
||||
_transaction.delete()
|
||||
return redirect(index)
|
||||
|
||||
|
||||
@login_required
|
||||
def invoice(request, uuid):
|
||||
_invoice = get_object_or_404(Invoice, id=uuid)
|
||||
|
|
Loading…
Reference in a new issue