This commit is contained in:
2026-04-04 01:16:16 +03:30
parent ecb42c6895
commit 6d5ece1f5d
22 changed files with 311 additions and 261 deletions
@@ -1,21 +1,24 @@
from django.core.management.base import BaseCommand, CommandError
from account.seeds import ADMIN_USER_DATA, seed_admin_user
from account.seeds import ADMIN_USER_DATA
from farm_hub.seeds import seed_admin_farm
class Command(BaseCommand):
help = "Create or update the default admin user."
help = "Create or update the default admin user through the admin farm seeder."
def handle(self, *args, **options):
try:
user, created = seed_admin_user()
farm, created = seed_admin_farm()
except ValueError as exc:
raise CommandError(str(exc)) from exc
action = "created" if created else "updated"
user = farm.owner
self.stdout.write(
self.style.SUCCESS(
f"Admin user {action}: username={user.username}, email={user.email}, "
f"phone_number={user.phone_number}, password={ADMIN_USER_DATA['password']}"
f"phone_number={user.phone_number}, password={ADMIN_USER_DATA['password']}, "
f"farm_uuid={farm.farm_uuid}"
)
)