From fe1f535ee623cc0848a58893bdbd6bc885157c64 Mon Sep 17 00:00:00 2001 From: hgh Date: Mon, 13 Oct 2025 15:49:53 +0330 Subject: [PATCH] FEATURE(pg):batch change payments to success/failed batch change payments to success/failed --- apps/pg/admin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/pg/admin.py b/apps/pg/admin.py index fa96731..00a1d9d 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -7,6 +7,7 @@ from django.db.models import Sum from django.http import HttpResponse from django.utils import timezone +from .constans import StateChoices from .models import PaymentRequest, PNA, Fake @@ -48,14 +49,22 @@ def export_exel(modeladmin, request, queryset): # return the response return response +@admin.action(description="change to success") +def change_to_success(model_admin, request, queryset): + for obj in queryset: + obj.change_state(StateChoices.WALLET_SUBMIT_SUCCESS, StateChoices.SUCCESS, 'change to success by admin') +@admin.action(description="change to failed") +def change_to_failed(model_admin, request, queryset): + for obj in queryset: + obj.change_state(StateChoices.WALLET_SUBMIT_SUCCESS, StateChoices.FAILED, 'change to failed by admin') class PaymentRequestAdmin(admin.ModelAdmin): list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway'] search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] list_filter = ['application', 'state', 'gateway'] - actions = [export_exel] + actions = [export_exel, change_to_success, change_to_failed] def changelist_view(self, request, extra_context=None):