Model palette tracks as typed symbol lanes
This commit is contained in:
parent
dff23d7994
commit
26fab9392e
20 changed files with 371 additions and 123 deletions
45
clips/migrations/0013_palette_track.py
Normal file
45
clips/migrations/0013_palette_track.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
"""Schema 4: split animated symbol palettes from the authoring palette.
|
||||
|
||||
Before schema 4 a symbol's ``:palette`` leaf value was always a channel. It now
|
||||
names the static palette used when that symbol is the viewed root, while the
|
||||
old channel is retained as ``:palette-channel`` compatibility data. New edits
|
||||
use a real lane symbol referenced by ``:palette-track``.
|
||||
"""
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def forwards(apps, schema_editor):
|
||||
Leaf = apps.get_model("clips", "Leaf")
|
||||
Project = apps.get_model("clips", "Project")
|
||||
for leaf in Leaf.objects.filter(path__contains="/symbol/"):
|
||||
parts = leaf.path.split("/")
|
||||
if len(parts) != 4 or parts[2] != "symbol":
|
||||
continue
|
||||
value = leaf.value
|
||||
if not (isinstance(value, list) and value[:1] == ["^ "]):
|
||||
continue
|
||||
out = list(value)
|
||||
changed = False
|
||||
for i in range(1, len(out) - 1, 2):
|
||||
if out[i] == "~:palette" and isinstance(out[i + 1], list):
|
||||
out[i] = "~:palette-channel"
|
||||
changed = True
|
||||
if changed:
|
||||
leaf.value = out
|
||||
leaf.version += 1
|
||||
leaf.save(update_fields=["value", "version"])
|
||||
Project.objects.update(schema_version=4)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [("clips", "0012_sound_label")]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="project",
|
||||
name="schema_version",
|
||||
field=models.PositiveIntegerField(default=4),
|
||||
),
|
||||
migrations.RunPython(forwards, migrations.RunPython.noop),
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue