Afegir control visual de les lletres per a partitures

This commit is contained in:
marc
2026-01-05 10:19:25 +01:00
parent c0624d1e56
commit 4e7a6b18d6
10 changed files with 65 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ from typing import TypedDict
from folkugat_web.dal.sql import Connection, get_connection
from folkugat_web.model import temes as model
LyricRowTuple = tuple[int, int, str, str]
LyricRowTuple = tuple[int, int, str, str, int | None]
class LyricRowDict(TypedDict):
@@ -12,6 +12,7 @@ class LyricRowDict(TypedDict):
tema_id: int
title: str
content: str
max_columns: int | None
def lyric_to_row(lyric: model.Lyrics) -> LyricRowDict:
@@ -20,6 +21,7 @@ def lyric_to_row(lyric: model.Lyrics) -> LyricRowDict:
"tema_id": lyric.tema_id,
"title": lyric.title,
"content": lyric.content,
"max_columns": lyric.max_columns,
}
@@ -29,6 +31,7 @@ def row_to_lyric(row: LyricRowTuple) -> model.Lyrics:
tema_id=row[1],
title=row[2],
content=row[3],
max_columns=row[4],
)
@@ -63,7 +66,7 @@ def get_lyrics(lyric_id: int | None = None, tema_id: int | None = None, con: Con
query = f"""
SELECT
id, tema_id, title, content
id, tema_id, title, content, max_columns
FROM tema_lyrics
{filter_clause}
"""
@@ -77,9 +80,9 @@ def insert_lyric(lyric: model.Lyrics, con: Connection | None = None) -> model.Ly
data = lyric_to_row(lyric)
query = f"""
INSERT INTO tema_lyrics
(id, tema_id, title, content)
(id, tema_id, title, content, max_columns)
VALUES
(:id, :tema_id, :title, :content)
(:id, :tema_id, :title, :content, :max_columns)
RETURNING *
"""
with get_connection(con) as con:
@@ -95,6 +98,7 @@ def create_lyric(tema_id: int, title: str | None = None, con: Connection | None
tema_id=tema_id,
title=title or "",
content="",
max_columns=None,
)
return insert_lyric(new_lyric, con=con)
@@ -104,7 +108,7 @@ def update_lyric(lyric: model.Lyrics, con: Connection | None = None):
query = """
UPDATE tema_lyrics
SET
tema_id = :tema_id, title = :title, content = :content
tema_id = :tema_id, title = :title, content = :content, max_columns = :max_columns
WHERE
id = :id
"""