From 212ea2541f2c8c09fe71275f11e072413c263fa0 Mon Sep 17 00:00:00 2001 From: i701 Date: Fri, 4 Jul 2025 16:32:45 +0500 Subject: [PATCH] =?UTF-8?q?refactor(billing):=20Simplify=20topup=20seeding?= =?UTF-8?q?=20by=20removing=20payment=20status=20and=20date=20logic=20?= =?UTF-8?q?=F0=9F=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- billing/management/commands/seed_topups.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/billing/management/commands/seed_topups.py b/billing/management/commands/seed_topups.py index 145b1c6..04261eb 100644 --- a/billing/management/commands/seed_topups.py +++ b/billing/management/commands/seed_topups.py @@ -4,9 +4,6 @@ import random from django.core.management.base import BaseCommand from django.utils import timezone from faker import Faker -from billing.models import ( - Payment, -) from billing.models import Topup from api.models import User @@ -40,12 +37,12 @@ class Command(BaseCommand): for _ in range(number): random_user = random.choice(users) - paid_status = fake.boolean(chance_of_getting_true=80) - paid_at_date = fake.date_time_this_year() if paid_status else None - - if paid_at_date and timezone.is_naive(paid_at_date): - paid_at_date = timezone.make_aware(paid_at_date) - + expires_at_date = timezone.now() + timezone.timedelta( + minutes=10, + ) + print( + f"Creating topup for user {getattr(random_user, 'id', None)} expires at: {expires_at_date}" + ) Topup.objects.create( amount=fake.pydecimal( left_digits=4, @@ -54,10 +51,9 @@ class Command(BaseCommand): min_value=100.00, max_value=5000.00, ), - paid=paid_status, user=random_user, - paid_at=paid_at_date, updated_at=timezone.now(), + expires_at=expires_at_date, ) self.stdout.write(self.style.SUCCESS(f"Successfully seeded {number} topups."))