CODEX - Added modal colours for the Bells
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Optional
|
||||
|
||||
DEFAULT_NOTE_ASSIGNMENT_COLORS: List[str] = [
|
||||
"#67E8F9", "#5EEAD4", "#6EE7B7", "#86EFAC",
|
||||
"#BEF264", "#FDE68A", "#FCD34D", "#FBBF24",
|
||||
"#FDBA74", "#FB923C", "#F97316", "#FB7185",
|
||||
"#F87171", "#EF4444", "#DC2626", "#B91C1C",
|
||||
]
|
||||
|
||||
|
||||
class MelodySettings(BaseModel):
|
||||
available_languages: List[str] = ["en", "el", "sr"]
|
||||
primary_language: str = "en"
|
||||
quick_colors: List[str] = ["#FF5733", "#33FF57", "#3357FF", "#FFD700", "#FF69B4", "#8B4513"]
|
||||
note_assignment_colors: List[str] = DEFAULT_NOTE_ASSIGNMENT_COLORS
|
||||
duration_values: List[int] = [
|
||||
0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180,
|
||||
240, 300, 360, 420, 480, 540, 600, 900,
|
||||
@@ -16,4 +24,5 @@ class MelodySettingsUpdate(BaseModel):
|
||||
available_languages: Optional[List[str]] = None
|
||||
primary_language: Optional[str] = None
|
||||
quick_colors: Optional[List[str]] = None
|
||||
note_assignment_colors: Optional[List[str]] = None
|
||||
duration_values: Optional[List[int]] = None
|
||||
|
||||
@@ -10,7 +10,10 @@ def get_melody_settings() -> MelodySettings:
|
||||
db = get_db()
|
||||
doc = db.collection(COLLECTION).document(DOC_ID).get()
|
||||
if doc.exists:
|
||||
return MelodySettings(**doc.to_dict())
|
||||
settings = MelodySettings(**doc.to_dict())
|
||||
# Backfill newly introduced defaults into stored settings.
|
||||
db.collection(COLLECTION).document(DOC_ID).set(settings.model_dump())
|
||||
return settings
|
||||
# Create with defaults
|
||||
defaults = MelodySettings()
|
||||
db.collection(COLLECTION).document(DOC_ID).set(defaults.model_dump())
|
||||
@@ -35,5 +38,6 @@ def update_melody_settings(data: MelodySettingsUpdate) -> MelodySettings:
|
||||
if "duration_values" in existing:
|
||||
existing["duration_values"] = sorted(existing["duration_values"])
|
||||
|
||||
doc_ref.set(existing)
|
||||
return MelodySettings(**existing)
|
||||
normalized = MelodySettings(**existing)
|
||||
doc_ref.set(normalized.model_dump())
|
||||
return normalized
|
||||
|
||||
Reference in New Issue
Block a user