FEATURE(pg):batch change payments to success/failed

batch change payments to success/failed
This commit is contained in:
hgh 2025-10-13 15:49:53 +03:30
parent 4281587396
commit fe1f535ee6

View file

@ -7,6 +7,7 @@ from django.db.models import Sum
from django.http import HttpResponse from django.http import HttpResponse
from django.utils import timezone from django.utils import timezone
from .constans import StateChoices
from .models import PaymentRequest, PNA, Fake from .models import PaymentRequest, PNA, Fake
@ -48,14 +49,22 @@ def export_exel(modeladmin, request, queryset):
# return the response # return the response
return 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): class PaymentRequestAdmin(admin.ModelAdmin):
list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway'] list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway']
search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid']
list_filter = ['application', 'state', 'gateway'] 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): def changelist_view(self, request, extra_context=None):