diff --git a/apps/pg/admin.py b/apps/pg/admin.py index 00a1d9d..c555afa 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -59,12 +59,18 @@ 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') +@admin.action(description="mark as registered") +def mark_as_registered(model_admin, request, queryset): + for obj in queryset: + obj.is_registered = True + obj.save(update_fields=['is_registered']) + 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', 'is_registered', 'created_at', 'application', 'gateway'] search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] list_filter = ['application', 'state', 'gateway'] - actions = [export_exel, change_to_success, change_to_failed] + actions = [export_exel, change_to_success, change_to_failed, mark_as_registered] def changelist_view(self, request, extra_context=None): diff --git a/apps/pg/migrations/0006_paymentrequest_is_registered.py b/apps/pg/migrations/0006_paymentrequest_is_registered.py new file mode 100644 index 0000000..1ce1a07 --- /dev/null +++ b/apps/pg/migrations/0006_paymentrequest_is_registered.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.4 on 2025-10-14 11:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pg', '0005_fake'), + ] + + operations = [ + migrations.AddField( + model_name='paymentrequest', + name='is_registered', + field=models.BooleanField(default=False), + ), + ] diff --git a/apps/pg/models.py b/apps/pg/models.py index 68589c6..af26d87 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -41,6 +41,8 @@ class PaymentRequest(models.Model): phone_number = models.CharField(max_length=255, null=True, blank=True) callback_url = models.CharField(max_length=255, null=True, blank=True) + is_registered = models.BooleanField(default=False) + created_at = models.DateTimeField(auto_now_add=True, db_index=True) updated_at = models.DateTimeField(auto_now=True, db_index=True)