Added stats
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import Request
|
||||
from fastapi import HTTPException, 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
|
||||
@@ -12,6 +10,8 @@ def title(request: Request, logged_in: bool, tema: model.Tema | None = None, tem
|
||||
if tema_id is None:
|
||||
raise ValueError("Either 'tema' or 'tema_id' must be given!")
|
||||
tema = temes_q.get_tema_by_id(tema_id)
|
||||
if not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/title.html",
|
||||
{
|
||||
@@ -24,6 +24,8 @@ def title(request: Request, logged_in: bool, tema: model.Tema | None = None, tem
|
||||
|
||||
def title_editor(request: Request, logged_in: bool, tema_id: int):
|
||||
tema = temes_q.get_tema_by_id(tema_id)
|
||||
if not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/editor/title.html",
|
||||
{
|
||||
@@ -36,8 +38,8 @@ def title_editor(request: Request, logged_in: bool, tema_id: 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 not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
lyric = tema.lyrics.get(lyric_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
@@ -54,8 +56,8 @@ def lyric(request: Request, logged_in: bool, tema_id: int, lyric_id: 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 not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
lyric = tema.lyrics.get(lyric_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
@@ -72,8 +74,8 @@ def lyric_editor(request: Request, logged_in: bool, tema_id: int, lyric_id: int)
|
||||
|
||||
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}")
|
||||
if not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
link = tema.links.get(link_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
@@ -95,8 +97,8 @@ def link(request: Request, logged_in: bool, tema_id: int, link_id: int):
|
||||
|
||||
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}")
|
||||
if not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
link = tema.links.get(link_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
@@ -115,8 +117,8 @@ def link_editor(request: Request, logged_in: bool, tema_id: int, link_id: int):
|
||||
|
||||
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}")
|
||||
if not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
link = tema.links.get(link_id)
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/editor/link_url.html",
|
||||
@@ -134,8 +136,8 @@ def link_editor_url(request: Request, logged_in: bool, tema_id: int, link_id: in
|
||||
|
||||
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}")
|
||||
if not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
link = tema.links.get(link_id)
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/editor/link_file.html",
|
||||
@@ -175,8 +177,8 @@ def link_icon(request: Request, logged_in: bool, tema_id: int, link_id: int, url
|
||||
|
||||
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}")
|
||||
if not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
return templates.TemplateResponse(
|
||||
"fragments/tema/score.html",
|
||||
{
|
||||
@@ -190,8 +192,8 @@ def score(request: Request, logged_in: bool, tema_id: int):
|
||||
|
||||
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}")
|
||||
if not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
prop = tema.properties.get(property_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
@@ -209,8 +211,8 @@ def property_(request: Request, logged_in: bool, tema_id: int, property_id: int)
|
||||
|
||||
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}")
|
||||
if not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
prop = tema.properties.get(property_id)
|
||||
|
||||
return templates.TemplateResponse(
|
||||
|
||||
Reference in New Issue
Block a user