mirror of
https://github.com/senju1337/senju.git
synced 2025-12-24 07:39:29 +00:00
feat: display the default haiku in the frontend with a small note
Refs: OPS-65
This commit is contained in:
parent
8f3ccb94d1
commit
da52e643a7
2 changed files with 11 additions and 8 deletions
|
|
@ -24,20 +24,18 @@ def index_view():
|
|||
def haiku_index_view():
|
||||
haiku_id: int | None = store.get_id_of_latest_haiku()
|
||||
if haiku_id is None:
|
||||
# TODO: add "empty haiku list" error page
|
||||
raise KeyError("no haiku exist yet")
|
||||
return redirect(url_for("haiku_view", haiku_id=haiku_id))
|
||||
haiku_id = 0
|
||||
return redirect(url_for("haiku_view", haiku_id=haiku_id, is_default=1))
|
||||
|
||||
|
||||
@app.route("/haiku/<int:haiku_id>")
|
||||
def haiku_view(haiku_id):
|
||||
"""test"""
|
||||
haiku: Haiku | None = store.load_haiku(haiku_id)
|
||||
if haiku is None:
|
||||
# TODO: add "haiku not found" page
|
||||
raise KeyError("haiku not found")
|
||||
is_default: bool = request.args.get("is_default") == "1"
|
||||
haiku: Haiku = store.load_haiku(haiku_id)
|
||||
context: dict = {
|
||||
"haiku": haiku
|
||||
"haiku": haiku,
|
||||
"is_default": is_default
|
||||
}
|
||||
|
||||
return render_template(
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@
|
|||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
{% if context.is_default %}
|
||||
<div class="mb-5">
|
||||
<b>Note:</b> No haikus have been found in the haiku store.
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('index_view') }}"
|
||||
class=" inline-block bg-violet-600 hover:bg-violet-700 text-white font-bold py-2 px-4 rounded-lg">
|
||||
Back to Home
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue