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():
|
def haiku_index_view():
|
||||||
haiku_id: int | None = store.get_id_of_latest_haiku()
|
haiku_id: int | None = store.get_id_of_latest_haiku()
|
||||||
if haiku_id is None:
|
if haiku_id is None:
|
||||||
# TODO: add "empty haiku list" error page
|
haiku_id = 0
|
||||||
raise KeyError("no haiku exist yet")
|
return redirect(url_for("haiku_view", haiku_id=haiku_id, is_default=1))
|
||||||
return redirect(url_for("haiku_view", haiku_id=haiku_id))
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/haiku/<int:haiku_id>")
|
@app.route("/haiku/<int:haiku_id>")
|
||||||
def haiku_view(haiku_id):
|
def haiku_view(haiku_id):
|
||||||
"""test"""
|
"""test"""
|
||||||
haiku: Haiku | None = store.load_haiku(haiku_id)
|
is_default: bool = request.args.get("is_default") == "1"
|
||||||
if haiku is None:
|
haiku: Haiku = store.load_haiku(haiku_id)
|
||||||
# TODO: add "haiku not found" page
|
|
||||||
raise KeyError("haiku not found")
|
|
||||||
context: dict = {
|
context: dict = {
|
||||||
"haiku": haiku
|
"haiku": haiku,
|
||||||
|
"is_default": is_default
|
||||||
}
|
}
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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') }}"
|
<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">
|
class=" inline-block bg-violet-600 hover:bg-violet-700 text-white font-bold py-2 px-4 rounded-lg">
|
||||||
Back to Home
|
Back to Home
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue