mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-23 09:08:39 +02:00
feat: add actions
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from .transactions import *
|
||||
from .tags import *
|
||||
from .categories import *
|
||||
from .actions import *
|
||||
|
||||
43
app/apps/transactions/views/actions.py
Normal file
43
app/apps/transactions/views/actions.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import HttpResponse
|
||||
|
||||
from apps.common.decorators.htmx import only_htmx
|
||||
from apps.transactions.models import Transaction
|
||||
|
||||
|
||||
@only_htmx
|
||||
@login_required
|
||||
def bulk_pay_transactions(request):
|
||||
selected_transactions = request.GET.getlist("transactions", [])
|
||||
Transaction.objects.filter(id__in=selected_transactions).update(is_paid=True)
|
||||
|
||||
return HttpResponse(
|
||||
status=204,
|
||||
headers={"HX-Trigger": "updated, toast, paid"},
|
||||
)
|
||||
|
||||
|
||||
@only_htmx
|
||||
@login_required
|
||||
def bulk_unpay_transactions(request):
|
||||
selected_transactions = request.GET.getlist("transactions", [])
|
||||
Transaction.objects.filter(id__in=selected_transactions).update(is_paid=False)
|
||||
|
||||
return HttpResponse(
|
||||
status=204,
|
||||
headers={"HX-Trigger": "updated, toast, unpaid"},
|
||||
)
|
||||
|
||||
|
||||
@only_htmx
|
||||
@login_required
|
||||
def bulk_delete_transactions(request):
|
||||
selected_transactions = request.GET.getlist("transactions", [])
|
||||
Transaction.objects.filter(
|
||||
id__in=selected_transactions, installment_plan__isnull=True
|
||||
).delete()
|
||||
|
||||
return HttpResponse(
|
||||
status=204,
|
||||
headers={"HX-Trigger": "updated, toast"},
|
||||
)
|
||||
Reference in New Issue
Block a user