From 40067a3aa5ce2da81507035420135f10836afd21 Mon Sep 17 00:00:00 2001 From: poduck Date: Wed, 17 Dec 2025 20:14:06 -0500 Subject: [PATCH] Make reseed_demo environment-aware for demo domain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use settings.DEBUG to detect production vs local environment - Production: demo.smoothschedule.com (https) - Local: demo.lvh.me:5173 (http) - Update existing domain if it doesn't match expected environment 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../management/commands/reseed_demo.py | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/smoothschedule/smoothschedule/scheduling/schedule/management/commands/reseed_demo.py b/smoothschedule/smoothschedule/scheduling/schedule/management/commands/reseed_demo.py index 20a7aff1..95f15ec5 100644 --- a/smoothschedule/smoothschedule/scheduling/schedule/management/commands/reseed_demo.py +++ b/smoothschedule/smoothschedule/scheduling/schedule/management/commands/reseed_demo.py @@ -20,6 +20,7 @@ import random from datetime import timedelta from decimal import Decimal +from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.core.management.base import BaseCommand from django.db import connection @@ -44,6 +45,20 @@ from smoothschedule.scheduling.schedule.models import ( class Command(BaseCommand): help = "Reseed demo tenant with fresh salon/spa data for sales demonstrations" + def get_demo_domain(self): + """Get the appropriate demo domain based on environment.""" + # Check if running in production + if hasattr(settings, 'DEBUG') and not settings.DEBUG: + return "demo.smoothschedule.com" + return "demo.lvh.me" + + def get_demo_url(self): + """Get the full demo URL based on environment.""" + domain = self.get_demo_domain() + if "smoothschedule.com" in domain: + return f"https://{domain}" + return f"http://{domain}:5173" + def add_arguments(self, parser): parser.add_argument( "--quiet", @@ -109,7 +124,7 @@ class Command(BaseCommand): self.stdout.write("\n" + "=" * 70) self.stdout.write(self.style.SUCCESS(" DEMO RESEED COMPLETE!")) self.stdout.write("=" * 70) - self.stdout.write("\nAccess URL: http://demo.lvh.me:5173") + self.stdout.write(f"\nAccess URL: {self.get_demo_url()}") self.stdout.write("All passwords: test123\n") def setup_tenant(self): @@ -140,13 +155,24 @@ class Command(BaseCommand): if not self.quiet: self.stdout.write(f" {self.style.SUCCESS('CREATED')} Demo tenant") - # Create domain - domain, created = Domain.objects.get_or_create( - domain="demo.lvh.me", - defaults={"tenant": tenant, "is_primary": True}, - ) - if created and not self.quiet: - self.stdout.write(f" {self.style.SUCCESS('CREATED')} Domain: demo.lvh.me") + # Create/update domain based on environment + demo_domain = self.get_demo_domain() + + # First, check if there's an existing primary domain that needs updating + existing_primary = Domain.objects.filter(tenant=tenant, is_primary=True).first() + if existing_primary and existing_primary.domain != demo_domain: + existing_primary.domain = demo_domain + existing_primary.save() + if not self.quiet: + self.stdout.write(f" {self.style.WARNING('UPDATED')} Domain: {demo_domain}") + elif not existing_primary: + Domain.objects.create( + domain=demo_domain, + tenant=tenant, + is_primary=True, + ) + if not self.quiet: + self.stdout.write(f" {self.style.SUCCESS('CREATED')} Domain: {demo_domain}") return tenant