Escollir partitura del tema en un set

This commit is contained in:
marc
2026-02-16 23:03:01 +01:00
parent 443c1b1391
commit 89f72dbb33
13 changed files with 1385 additions and 22 deletions

View File

@@ -20,6 +20,7 @@ class PlaylistEntry:
playlist_id: int
set_id: int
tema_id: int | None
score_id: int | None = None
@dataclasses.dataclass
@@ -27,6 +28,7 @@ class TemaInSet:
id: int | None
tema_id: int | None
tema: Tema | None
score_id: int | None = None
def to_playlist_entry(self, playlist_id: int, set_id: int) -> PlaylistEntry:
return PlaylistEntry(
@@ -34,6 +36,7 @@ class TemaInSet:
playlist_id=playlist_id,
set_id=set_id,
tema_id=self.tema_id,
score_id=self.score_id,
)
@classmethod
@@ -42,8 +45,19 @@ class TemaInSet:
id=entry.id,
tema_id=entry.tema_id,
tema=None,
score_id=entry.score_id,
)
def get_effective_score(self):
"""Returns the specified score if set, otherwise falls back to main_score()."""
if self.tema is None:
return None
if self.score_id is not None:
for score in self.tema.scores:
if score.id == self.score_id:
return score
return self.tema.main_score()
@dataclasses.dataclass
class SetScore: