parks working
This commit is contained in:
parent
f95f2e03c1
commit
bd23e2c3ef
8
app.py
8
app.py
@ -11,7 +11,7 @@ def parks():
|
||||
global _data
|
||||
if not _data:
|
||||
with open("data/parks.json") as f:
|
||||
_data = {p["id"]: p for p in json.load(f)}
|
||||
_data = {int(p["id"]): p for p in json.load(f)}
|
||||
return _data
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ def about():
|
||||
|
||||
|
||||
@app.route("/parks")
|
||||
def staff():
|
||||
def park_list():
|
||||
page = int(request.args.get("page", 1))
|
||||
per_page = 10
|
||||
total_items = len(parks())
|
||||
@ -45,7 +45,7 @@ def staff():
|
||||
|
||||
@app.route("/parks/<id_>")
|
||||
def park_detail(id_):
|
||||
if park := parks().get(id_):
|
||||
return render_template("staff_detail.html", employee=employee)
|
||||
if park := parks().get(int(id_)):
|
||||
return render_template("park_detail.html", park=park)
|
||||
else:
|
||||
abort(404)
|
||||
|
29
templates/park_detail.html
Normal file
29
templates/park_detail.html
Normal file
@ -0,0 +1,29 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block base %}
|
||||
<div class="card fluid">
|
||||
<h2 class="section">{{ park.title }}</h2>
|
||||
<div class="section">
|
||||
<dl>
|
||||
<dt>Address</dt>
|
||||
<dd id="address">
|
||||
{% autoescape false %}
|
||||
{{ park.address|replace("\n","<br>") }}
|
||||
{% endautoescape %}
|
||||
</dd>
|
||||
<dt>About</dt>
|
||||
<dd id="children">
|
||||
{% autoescape false %}
|
||||
{{ park.description|replace("\n","<br>") }}
|
||||
{% endautoescape %}
|
||||
</dd>
|
||||
<dt>History</dt>
|
||||
<dd id="hired">
|
||||
{% autoescape false %}
|
||||
{{ park.history|replace("\n","<br>") }}
|
||||
{% endautoescape %}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -17,7 +17,7 @@
|
||||
<tr>
|
||||
<td>{{ e.title }}</td>
|
||||
<td>{{ e.address }}</td>
|
||||
<td><a href="/staff/{{ e.id }}">Details</a></td>
|
||||
<td><a href="/parks/{{ e.id }}">Details</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
@ -1,19 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block base %}
|
||||
<div class="card fluid">
|
||||
<h2 class="section">Employee Details for {{ employee.first }} {{ employee.last }}</h2>
|
||||
<div class="section">
|
||||
<dl>
|
||||
<dt>Position</dt>
|
||||
<dd id="position">{{ employee.position }}</dd>
|
||||
<dt>Marital Status</dt>
|
||||
<dd id="status">{{ employee.status }}</dd>
|
||||
<dt>Number of Children</dt>
|
||||
<dd id="children">{{ employee.children }}</dd>
|
||||
<dt>Hired</dt>
|
||||
<dd id="hired">{{ employee.hired }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user