Added indexed lists and link edition in tunes
This commit is contained in:
@@ -25,11 +25,10 @@ def footer(request, value, logged_in):
|
||||
|
||||
|
||||
def nota(request):
|
||||
response = templates.TemplateResponse(
|
||||
return templates.TemplateResponse(
|
||||
"fragments/nota/nota.html",
|
||||
{
|
||||
"request": request,
|
||||
}
|
||||
},
|
||||
headers={"HX-Refresh": "true"},
|
||||
)
|
||||
response.headers["HX-Refresh"] = "true"
|
||||
return response
|
||||
|
||||
@@ -3,6 +3,7 @@ from typing import Optional
|
||||
from fastapi import Request
|
||||
from folkugat_web.model import temes as model
|
||||
from folkugat_web.services.temes import query as temes_q
|
||||
from folkugat_web.services.temes.links import guess_link_type
|
||||
from folkugat_web.templates import templates
|
||||
|
||||
|
||||
@@ -33,13 +34,11 @@ def title_editor(request: Request, logged_in: bool, tema_id: int):
|
||||
)
|
||||
|
||||
|
||||
def lyric(request: Request, logged_in: bool, tema_id: int, lyric_idx: int):
|
||||
def lyric(request: Request, logged_in: bool, tema_id: int, lyric_id: int):
|
||||
tema = temes_q.get_tema_by_id(tema_id)
|
||||
if tema is None:
|
||||
raise ValueError(f"No tune exists for tema_id: {tema_id}")
|
||||
if len(tema.lyrics) < lyric_idx:
|
||||
raise ValueError(f'Lyric index out of bounds')
|
||||
lyric = tema.lyrics[lyric_idx]
|
||||
lyric = tema.lyrics.get(lyric_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/lyric.html",
|
||||
@@ -47,19 +46,17 @@ def lyric(request: Request, logged_in: bool, tema_id: int, lyric_idx: int):
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
"lyric_idx": lyric_idx,
|
||||
"lyric_id": lyric_id,
|
||||
"lyric": lyric,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def lyric_editor(request: Request, logged_in: bool, tema_id: int, lyric_idx: int):
|
||||
def lyric_editor(request: Request, logged_in: bool, tema_id: int, lyric_id: int):
|
||||
tema = temes_q.get_tema_by_id(tema_id)
|
||||
if tema is None:
|
||||
raise ValueError(f"No tune exists for tema_id: {tema_id}")
|
||||
if len(tema.lyrics) < lyric_idx:
|
||||
raise ValueError(f'Lyric index out of bounds')
|
||||
lyric = tema.lyrics[lyric_idx]
|
||||
lyric = tema.lyrics.get(lyric_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/editor/lyric.html",
|
||||
@@ -67,7 +64,75 @@ def lyric_editor(request: Request, logged_in: bool, tema_id: int, lyric_idx: int
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
"lyric_idx": lyric_idx,
|
||||
"lyric_id": lyric_id,
|
||||
"lyric": lyric,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def link(request: Request, logged_in: bool, tema_id: int, link_id: int):
|
||||
tema = temes_q.get_tema_by_id(tema_id)
|
||||
if tema is None:
|
||||
raise ValueError(f"No tune exists for tema_id: {tema_id}")
|
||||
link = tema.links.get(link_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/link.html",
|
||||
{
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
"link_id": link_id,
|
||||
"link": link,
|
||||
"LinkType": model.LinkType,
|
||||
"ContentType": model.ContentType,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def link_editor(request: Request, logged_in: bool, tema_id: int, link_id: int):
|
||||
tema = temes_q.get_tema_by_id(tema_id)
|
||||
if tema is None:
|
||||
raise ValueError(f"No tune exists for tema_id: {tema_id}")
|
||||
link = tema.links.get(link_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/editor/link.html",
|
||||
{
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
"link_id": link_id,
|
||||
"link": link,
|
||||
"LinkType": model.LinkType,
|
||||
"ContentType": model.ContentType,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def link_icon(
|
||||
request: Request,
|
||||
logged_in: bool,
|
||||
tema_id: int,
|
||||
link_id: int,
|
||||
url: str,
|
||||
content_type: model.ContentType,
|
||||
):
|
||||
link = model.Link(
|
||||
id=link_id,
|
||||
content_type=content_type,
|
||||
link_type=guess_link_type(url),
|
||||
url=url,
|
||||
)
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/link_icon.html",
|
||||
{
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema_id": tema_id,
|
||||
"link_id": link_id,
|
||||
"link": link,
|
||||
"LinkType": model.LinkType,
|
||||
"ContentType": model.ContentType,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -25,8 +25,8 @@ def temes_busca_result(request: Request, tema: model.Tema, logged_in: bool):
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
"LinkSubtype": model.LinkSubtype,
|
||||
"LinkType": model.LinkType,
|
||||
"ContentType": model.ContentType,
|
||||
}
|
||||
).body.decode('utf-8')
|
||||
|
||||
@@ -47,8 +47,8 @@ def tema(request: Request, tema_id: int, logged_in: bool):
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"Pages": Pages,
|
||||
"LinkSubtype": model.LinkSubtype,
|
||||
"LinkType": model.LinkType,
|
||||
"ContentType": model.ContentType,
|
||||
"tema": tema,
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user