From 63764f54ba2cfc9888133bac74d716c93ac519b1 Mon Sep 17 00:00:00 2001 From: imperosol Date: Tue, 22 Sep 2026 11:04:18 +0200 Subject: [PATCH] better subscription generation in populate_more --- core/management/commands/populate_more.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/management/commands/populate_more.py b/core/management/commands/populate_more.py index 3262fe46..544be7c1 100644 --- a/core/management/commands/populate_more.py +++ b/core/management/commands/populate_more.py @@ -144,10 +144,22 @@ class Command(BaseCommand): ) def create_subscriptions(self, users: list[User]): + subscription_types = [ + "un-semestre", + "deux-semestres", + "cursus-tronc-commun", + "cursus-branche", + ] + def prepare_subscription(_user: User, start_date: date) -> Subscription: payment_method = random.choice(settings.SITH_SUBSCRIPTION_PAYMENT_METHOD)[0] - duration = random.randint(1, 4) - s = Subscription(member=_user, payment_method=payment_method) + subscription_type = random.choice(subscription_types) + s = Subscription( + member=_user, + payment_method=payment_method, + subscription_type=subscription_type, + ) + duration = settings.SITH_SUBSCRIPTIONS[subscription_type]["duration"] s.subscription_start = s.compute_start(d=start_date, duration=duration) s.subscription_end = s.compute_end(duration) return s