diff --git a/src/utils/management/commands/bootstrap_dev_data.py b/src/utils/management/commands/bootstrap_dev_data.py index a1d04f8..e95476f 100644 --- a/src/utils/management/commands/bootstrap_dev_data.py +++ b/src/utils/management/commands/bootstrap_dev_data.py @@ -1,7 +1,11 @@ """Command to bootstrap development data.""" +from datetime import timedelta +from django.utils import timezone +from django.db.backends.postgresql.psycopg_any import DateRange from django.contrib.auth.models import User from django.core.management import BaseCommand +from membership.models import SubscriptionPeriod class Command(BaseCommand): @@ -16,6 +20,7 @@ class Command(BaseCommand): """Handle the command.""" self.create_superuser() self.create_normal_users() + self.create_subscription_periods() def create_superuser(self) -> None: """Create superuser.""" @@ -31,3 +36,13 @@ class Command(BaseCommand): for user in self.normal_users: user.set_password(user.username) user.save() + + def create_subscription_periods(self) -> None: + """Create subscription periods.""" + self.stdout.write("Creating subscription periods") + SubscriptionPeriod.objects.create( + period=DateRange(timezone.now().date() - timedelta(days=182), timezone.now().date() + timedelta(days=183)) + ) + SubscriptionPeriod.objects.create( + period=DateRange(timezone.now().date() + timedelta(days=183), timezone.now().date() + timedelta(days=365)) + )