Merge pull request 'FEATURE/adding_is_registered_to_payment_request' (#2) from FEATURE/adding_is_registered_to_payment_request into master

Reviewed-on: addwin/pg#2
Reviewed-by: Sayyid Hamid Mahdavi <sahama@noreply.localhost>
This commit is contained in:
Sayyid Hamid Mahdavi 2025-10-25 08:22:33 -04:00
commit 36a5f17ceb
3 changed files with 28 additions and 1 deletions

View file

@ -64,12 +64,19 @@ def change_to_failed(model_admin, request, queryset):
for obj in queryset: for obj in queryset:
obj.change_state(StateChoices.WALLET_SUBMIT_SUCCESS, StateChoices.FAILED, 'change to failed by admin') 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): class PaymentRequestAdmin(admin.ModelAdmin):
list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'is_registered', 'created_at', 'application', 'gateway']
list_display = ['state', 'check_success_again', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway'] list_display = ['state', 'check_success_again', '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, 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): def changelist_view(self, request, extra_context=None):

View file

@ -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),
),
]

View file

@ -42,6 +42,8 @@ class PaymentRequest(models.Model):
phone_number = models.CharField(max_length=255, null=True, blank=True) phone_number = models.CharField(max_length=255, null=True, blank=True)
callback_url = 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) created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True, db_index=True) updated_at = models.DateTimeField(auto_now=True, db_index=True)