Add Django backend: users, admin, OTIO + scene persistence
A Project (owner, OTIO file, fps, scene JSON) persists the timeline. Session API: list projects, GET/PUT scene, serve OTIO. Admin manages users/projects; seed_demo creates a project from the bundled one_two_three.otio. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
7a960afb5c
commit
57ef570539
21 changed files with 406 additions and 0 deletions
31
scenes/management/commands/seed_demo.py
Normal file
31
scenes/management/commands/seed_demo.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
"""Create a demo Project owned by `admin`, with the bundled OTIO attached."""
|
||||
from pathlib import Path
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.files import File
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from scenes.models import Project
|
||||
|
||||
OTIO = settings.BASE_DIR / "tl" / "resources" / "public" / "one_two_three.otio"
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Seed a demo project from the bundled OTIO file."
|
||||
|
||||
def handle(self, *args, **opts):
|
||||
User = get_user_model()
|
||||
owner = User.objects.filter(username="admin").first()
|
||||
if owner is None:
|
||||
self.stderr.write("no 'admin' user — run createsuperuser first")
|
||||
return
|
||||
|
||||
project, created = Project.objects.get_or_create(
|
||||
owner=owner, name="one two three", defaults={"scene": {}})
|
||||
if OTIO.exists() and not project.otio:
|
||||
with OTIO.open("rb") as fh:
|
||||
project.otio.save(Path(OTIO).name, File(fh), save=True)
|
||||
|
||||
verb = "created" if created else "exists"
|
||||
self.stdout.write(f"project #{project.pk} {verb}: {project.name} (otio={bool(project.otio)})")
|
||||
Loading…
Add table
Add a link
Reference in a new issue