Tune editor
This commit is contained in:
@@ -86,6 +86,9 @@ def link(request: Request, logged_in: bool, tema_id: int, link_id: int):
|
||||
"link": link,
|
||||
"LinkType": model.LinkType,
|
||||
"ContentType": model.ContentType,
|
||||
},
|
||||
headers={
|
||||
"HX-Trigger": f"reload-tema-{tema_id}-score"
|
||||
}
|
||||
)
|
||||
|
||||
@@ -110,14 +113,46 @@ def link_editor(request: Request, logged_in: bool, tema_id: int, link_id: int):
|
||||
)
|
||||
|
||||
|
||||
def link_icon(
|
||||
request: Request,
|
||||
logged_in: bool,
|
||||
tema_id: int,
|
||||
link_id: int,
|
||||
url: str,
|
||||
content_type: model.ContentType,
|
||||
):
|
||||
def link_editor_url(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_url.html",
|
||||
{
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
"link_id": link_id,
|
||||
"link": link,
|
||||
"LinkType": model.LinkType,
|
||||
"ContentType": model.ContentType,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def link_editor_file(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_file.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,
|
||||
@@ -136,3 +171,67 @@ def link_icon(
|
||||
"ContentType": model.ContentType,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def score(request: Request, logged_in: bool, tema_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}")
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/score.html",
|
||||
{
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
"LinkType": model.LinkType,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def property_(request: Request, logged_in: bool, tema_id: int, property_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}")
|
||||
prop = tema.properties.get(property_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/property.html",
|
||||
{
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
"property_id": property_id,
|
||||
"property": prop,
|
||||
"PropertyField": model.PropertyField,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def property_editor(request: Request, logged_in: bool, tema_id: int, property_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}")
|
||||
prop = tema.properties.get(property_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/editor/property.html",
|
||||
{
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
"property_id": property_id,
|
||||
"property": prop,
|
||||
"PropertyField": model.PropertyField,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def visibility(request: Request, logged_in: bool, tema: model.Tema):
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/visibility.html",
|
||||
{
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -6,36 +6,30 @@ from folkugat_web.services.temes import search as temes_s
|
||||
from folkugat_web.templates import templates
|
||||
|
||||
|
||||
def temes_pagina(request: Request, logged_in: bool):
|
||||
def temes_pagina(request: Request, logged_in: bool, query: str):
|
||||
return templates.TemplateResponse(
|
||||
"fragments/temes/pagina.html",
|
||||
{
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"query": query,
|
||||
"Pages": Pages,
|
||||
"menu_selected_id": Pages.Temes,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def temes_busca_result(request: Request, tema: model.Tema, logged_in: bool):
|
||||
def temes_busca(request: Request, query: str, logged_in: bool):
|
||||
temes = temes_s.busca_temes(query=query, hidden=logged_in)
|
||||
return templates.TemplateResponse(
|
||||
"fragments/temes/result.html",
|
||||
"fragments/temes/results.html",
|
||||
{
|
||||
"request": request,
|
||||
"logged_in": logged_in,
|
||||
"tema": tema,
|
||||
"temes": temes,
|
||||
"LinkType": model.LinkType,
|
||||
"ContentType": model.ContentType,
|
||||
}
|
||||
).body.decode('utf-8')
|
||||
|
||||
|
||||
def temes_busca(request: Request, query: str, logged_in: bool):
|
||||
temes = temes_s.busca_temes(query)
|
||||
return '\n'.join(
|
||||
[temes_busca_result(request, tema, logged_in)
|
||||
for tema in temes]
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user