Fix page spacing and add daily poetry with manual write testing
This commit is contained in:
@@ -69,7 +69,26 @@ class TemplateRenderer:
|
||||
"星期日 / Sunday",
|
||||
][current.weekday()],
|
||||
)
|
||||
if "weather" not in values:
|
||||
if template_id == "daily-poetry" and not values.get("poem_lines"):
|
||||
from pigway_frame_flow.providers.poetry import get_poem
|
||||
|
||||
try:
|
||||
poem = get_poem(values["date"], values.get("poem_id"))
|
||||
except ValueError:
|
||||
raise FlowError(
|
||||
E.INVALID_REQUEST, "Invalid poetry date or poem selection"
|
||||
) from None
|
||||
values.update(
|
||||
poem_id=poem["id"],
|
||||
poem_title=poem["title"],
|
||||
poem_author=poem["author"],
|
||||
poem_lines=poem["lines"],
|
||||
poem_source=poem["source"],
|
||||
poem_edition=poem["edition"],
|
||||
)
|
||||
if "weather" not in values and any(
|
||||
b.get("field") in ("weather", "forecast") for b in spec["blocks"]
|
||||
):
|
||||
values["weather"] = self.weather.get_current()
|
||||
if (
|
||||
any(b.get("field") == "forecast" for b in spec["blocks"])
|
||||
|
||||
Reference in New Issue
Block a user