Escollir partitura del tema en un set
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user