start the django

This commit is contained in:
Ross
2025-12-09 10:01:04 +00:00
parent a230c9d94c
commit 4927697621
14 changed files with 511 additions and 7 deletions
+1
View File
@@ -0,0 +1 @@
# package
@@ -0,0 +1 @@
# package
@@ -0,0 +1,23 @@
from django.core.management.base import BaseCommand, CommandError
from rota.models import RotaSchedule
from rota.services import run_rota_async
class Command(BaseCommand):
help = "Create a RotaRun for the given RotaSchedule id and start it in background."
def add_arguments(self, parser):
parser.add_argument("rota_id", type=int)
parser.add_argument("--external", action="store_true", help="Use external generator hook if available")
def handle(self, *args, **options):
rota_id = options["rota_id"]
use_external = options.get("external", False)
try:
rota = RotaSchedule.objects.get(pk=rota_id)
except RotaSchedule.DoesNotExist:
raise CommandError(f"RotaSchedule with id={rota_id} not found")
run = run_rota_async(rota.id, use_external_generator=use_external)
self.stdout.write(self.style.SUCCESS(f"Started RotaRun id={run.id} for rota={rota.name}"))