diff --git a/README.org b/README.org index 1631993..f8cf541 100644 --- a/README.org +++ b/README.org @@ -1,7 +1,7 @@ #+title: Readme * Tasques -** TODO Ordenar els resultats de la cerca de temes +** DONE Ordenar els resultats de la cerca de temes ** TODO Suport per a diverses organitzacions (no només jam de Sant Cugat) ** TODO Usuaris i permisos granulars ** Lilypond support diff --git a/folkugat_web/api/routes/tema/index.py b/folkugat_web/api/routes/tema/index.py index ec74e25..0043a54 100644 --- a/folkugat_web/api/routes/tema/index.py +++ b/folkugat_web/api/routes/tema/index.py @@ -1,3 +1,4 @@ +import dataclasses from typing import Annotated from fastapi import HTTPException, Request @@ -5,6 +6,7 @@ from fastapi.params import Form from fastapi.responses import HTMLResponse from folkugat_web.api.router import get_router from folkugat_web.fragments import tema, temes +from folkugat_web.model.temes import Tema from folkugat_web.services import auth from folkugat_web.services import files as files_service from folkugat_web.services.temes import links as links_service @@ -32,6 +34,21 @@ def page(request: Request, logged_in: auth.LoggedIn, tema_id: int): ) +def augment_played_with(tema: Tema) -> Tema: + if tema.played_with: + tema.played_with = [ + dataclasses.replace( + co_tema, + tema=( + FnChain.transform(co_tema.tema) | + scores_service.add_scores_to_tema | + properties_service.add_properties_to_tema + ).result() + ) for co_tema in tema.played_with + ] + return tema + + @router.get("/api/tema/{tema_id}") def contingut(request: Request, logged_in: auth.LoggedIn, tema_id: int): tema = temes_q.get_tema_by_id(tema_id) @@ -40,6 +57,8 @@ def contingut(request: Request, logged_in: auth.LoggedIn, tema_id: int): tema = ( FnChain.transform(tema) | temes_q.tema_compute_stats | + temes_q.tema_compute_played_with | + augment_played_with | links_service.add_links_to_tema | lyrics_service.add_lyrics_to_tema | scores_service.add_scores_to_tema | diff --git a/folkugat_web/assets/static/css/main.css b/folkugat_web/assets/static/css/main.css index 3185b00..80e96f7 100644 --- a/folkugat_web/assets/static/css/main.css +++ b/folkugat_web/assets/static/css/main.css @@ -657,6 +657,10 @@ video { margin-left: 0.5rem; } +.ml-4 { + margin-left: 1rem; +} + .ml-auto { margin-left: auto; } diff --git a/folkugat_web/assets/templates/fragments/tema/played_with.html b/folkugat_web/assets/templates/fragments/tema/played_with.html new file mode 100644 index 0000000..9759c8c --- /dev/null +++ b/folkugat_web/assets/templates/fragments/tema/played_with.html @@ -0,0 +1,40 @@ +
- Aquest tema ha sigut tocat en - {% if tema.stats.times_played == 1%} - una sessió. - {% else %} - {{ tema.stats.times_played }} sessions. - {% endif %} -
-- S'ha tocat a les sessions següents: -
+ S'ha tocat juntament amb: +
++ S'ha tocat en + {% if tema.stats.times_played == 1%} + una sessió: + {% else %} + {{ tema.stats.times_played }} sessions: + {% endif %} +
++ {% set dn = date_names(session.date) %} {{ dn.day_name }} {{ dn.day }} {{ dn.month_name }} +
+ +