employee detail pages
This commit is contained in:
parent
856480fecc
commit
10ddd75632
20
app.py
20
app.py
@ -3,10 +3,16 @@ from flask import Flask, render_template
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
_employees = {}
|
||||||
|
|
||||||
|
|
||||||
def employees():
|
def employees():
|
||||||
|
# thanks to http://www.figmentfly.com/bb/badguys3.html for names
|
||||||
|
global _employees
|
||||||
|
if not _employees:
|
||||||
with open("data/employees.csv") as f:
|
with open("data/employees.csv") as f:
|
||||||
employees = list(csv.DictReader(f))
|
_employees = {e["id"]: e for e in csv.DictReader(f)}
|
||||||
|
return _employees
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
@ -21,8 +27,12 @@ def about():
|
|||||||
|
|
||||||
@app.route("/staff")
|
@app.route("/staff")
|
||||||
def staff():
|
def staff():
|
||||||
# thanks to http://www.figmentfly.com/bb/badguys3.html for names
|
return render_template("staff.html", employees=employees().values())
|
||||||
with open("data/employees.csv") as f:
|
|
||||||
employees = list(csv.DictReader(f))
|
|
||||||
|
|
||||||
return render_template("staff.html", employees=employees)
|
|
||||||
|
@app.route("/staff/<id_>")
|
||||||
|
def staff_detail(id_):
|
||||||
|
if employee := employees().get(id_):
|
||||||
|
return render_template("staff_detail.html", employee=employee)
|
||||||
|
else:
|
||||||
|
raise 404
|
||||||
|
@ -1,46 +1,46 @@
|
|||||||
first,last,position,status,children,hired
|
id,first,last,position,status,children,hired
|
||||||
John,Barnett,Scheduling,Married,1,3/6/1963
|
52,John,Barnett,Scheduling,Married,1,3/6/1963
|
||||||
John,Bigbooté,Executive Vice President,Single,0,10/31/1938
|
2,John,Bigbooté,Executive Vice President,Single,0,10/31/1938
|
||||||
John,Camp,Human Resources,Single,0,6/12/1985
|
13,John,Camp,Human Resources,Single,0,6/12/1985
|
||||||
John,Careful Walker,Accounting,Single,0,4/30/1990
|
14,John,Careful Walker,Accounting,Single,0,4/30/1990
|
||||||
John,Chief Crier,"VP, Public Relations",Married,2,4/2/1980
|
15,John,Chief Crier,"VP, Public Relations",Married,2,4/2/1980
|
||||||
John,Cooper,Storage Acquisition,Single,0,8/15/1984
|
16,John,Cooper,Storage Acquisition,Single,0,8/15/1984
|
||||||
John,Coyote,Medical Research,Married,6,1/1/1970
|
17,John,Coyote,Medical Research,Married,6,1/1/1970
|
||||||
John,Edwards,Public Relations,Divorced,2,8/15/1984
|
18,John,Edwards,Public Relations,Divorced,2,8/15/1984
|
||||||
John,Fat Eating,Craft Services,Single,0,8/15/1984
|
19,John,Fat Eating,Craft Services,Single,0,8/15/1984
|
||||||
John,Fish,Marine R&D,Divorced,12,10/31/1938
|
20,John,Fish,Marine R&D,Divorced,12,10/31/1938
|
||||||
John,Fledgling,Human Resources,Married,2,7/4/1976
|
21,John,Fledgling,Human Resources,Married,2,7/4/1976
|
||||||
John,Gomez,"VP, Sales",Married,1,8/15/1984
|
22,John,Gomez,"VP, Sales",Married,1,8/15/1984
|
||||||
John,Grim,Actuary,Married,1.8,9/9/1970
|
23,John,Grim,Actuary,Married,1.8,9/9/1970
|
||||||
John,Guardian,Optical Systems Engineer,Single,0,6/9/1980
|
24,John,Guardian,Optical Systems Engineer,Single,0,6/9/1980
|
||||||
John,Icicle Boy,Refrigeration R&D,Single,0,2/6/1939
|
25,John,Icicle Boy,Refrigeration R&D,Single,0,2/6/1939
|
||||||
John,Jones,Government Relations,Married,3,8/15/1984
|
26,John,Jones,Government Relations,Married,3,8/15/1984
|
||||||
John,Joseph,Government Relations,Married,2,10/31/1938
|
27,John,Joseph,Government Relations,Married,2,10/31/1938
|
||||||
John,Kim Chi,Craft Services,Married,2,7/24/1990
|
28,John,Kim Chi,Craft Services,Married,2,7/24/1990
|
||||||
John,Lee,Accounting,Single,0,12/14/1988
|
29,John,Lee,Accounting,Single,0,12/14/1988
|
||||||
John,Littlejohn,Staff Parlementarian,Divorced,0,10/31/1938
|
30,John,Littlejohn,Staff Parlementarian,Divorced,0,10/31/1938
|
||||||
John,Many Jars,Storage Acquisition Lead,Married,3,1/8/1960
|
31,John,Many Jars,Storage Acquisition Lead,Married,3,1/8/1960
|
||||||
John,Milton,Chief Counsel,Single,2,6/6/1966
|
666,John,Milton,Chief Counsel,Single,2,6/6/1966
|
||||||
John,Mud Head,Apian Research Lead,Married,7,1/2/1956
|
32,John,Mud Head,Apian Research Lead,Married,7,1/2/1956
|
||||||
John,Nephew,Temporal Paradox Resolution,Widowed,0,1/20/1474
|
33,John,Nephew,Temporal Paradox Resolution,Widowed,0,1/20/1474
|
||||||
John,Nolan,Custodian,Married,2,10/31/1938
|
34,John,Nolan,Custodian,Married,2,10/31/1938
|
||||||
John,O'Connor,Temporal Paradox Resolution,Widowed,1,5/15/2022
|
35,John,O'Connor,Temporal Paradox Resolution,Widowed,1,5/15/2022
|
||||||
John,Omar,Imports & Exports,Single,0,9/9/1963
|
37,John,Omar,Imports & Exports,Single,0,9/9/1963
|
||||||
John,Parrot,Computer Design Specialist,Married,1,10/1/1970
|
38,John,Parrot,Computer Design Specialist,Married,1,10/1/1970
|
||||||
John,Rajeesh,Human Resources,Divorced,1,6/12/1982
|
39,John,Rajeesh,Human Resources,Divorced,1,6/12/1982
|
||||||
John,Ready to Fly,Aerial R&D,Married,1,7/4/1976
|
11,John,Ready to Fly,Aerial R&D,Married,1,7/4/1976
|
||||||
John,Repeat Dance,Sales,Married,3,6/8/1949
|
40,John,Repeat Dance,Sales,Married,3,6/8/1949
|
||||||
John,Roberts,Counsel,Married,0,4/1/1962
|
50,John,Roberts,Counsel,Married,0,4/1/1962
|
||||||
John,Scott,Administration,Single,1,10/31/1938
|
51,John,Scott,Administration,Single,1,10/31/1938
|
||||||
John,Shaw,Administration,Single,0,8/15/1984
|
59,John,Shaw,Administration,Single,0,8/15/1984
|
||||||
John,Small Berries,Orbital Ergonomitrics Team Leader,Married,3,10/17/1948
|
3,John,Small Berries,Orbital Ergonomitrics Team Leader,Married,3,10/17/1948
|
||||||
John,Starbird,Orbital Ergonomitrics,Married,2,10/18/1948
|
4,John,Starbird,Orbital Ergonomitrics,Married,2,10/18/1948
|
||||||
John,Take Cover,Security Administrator,Divorced,0,2/15/2019
|
5,John,Take Cover,Security Administrator,Divorced,0,2/15/2019
|
||||||
John,Thorny Stick,Sales,Married,0,8/15/1984
|
6,John,Thorny Stick,Sales,Married,0,8/15/1984
|
||||||
John,Turk,System Administrator,Engaged,0,11/3/1986
|
7,John,Turk,System Administrator,Engaged,0,11/3/1986
|
||||||
John,Two Horns,Paralegal,Married,0,8/15/1984
|
8,John,Two Horns,Paralegal,Married,0,8/15/1984
|
||||||
John,Web,IT Support,Married,1,6/8/1949
|
9,John,Web,IT Support,Married,1,6/8/1949
|
||||||
John,Whorfin,CEO / Lord,Single,0,10/31/1938
|
1,John,Whorfin,CEO / Lord,Single,0,10/31/1938
|
||||||
John,Wood,Sales,Married,1,8/12/1948
|
99,John,Wood,Sales,Married,1,8/12/1948
|
||||||
John,Wright,Orbital Mechanics Supervisor,Married,2,10/4/1985
|
100,John,Wright,Orbital Mechanics Supervisor,Married,2,10/4/1985
|
||||||
John,Ya Ya,Computer Design Specialist,Married,0,10/31/1938
|
101,John,Ya Ya,Computer Design Specialist,Married,0,10/31/1938
|
||||||
|
|
@ -10,8 +10,7 @@
|
|||||||
<th>First Name</th>
|
<th>First Name</th>
|
||||||
<th>Last Name</th>
|
<th>Last Name</th>
|
||||||
<th>Position Name</th>
|
<th>Position Name</th>
|
||||||
<th>Status</th>
|
<th> </th>
|
||||||
<th>Hired</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -20,8 +19,7 @@
|
|||||||
<td>{{ e.first }}</td>
|
<td>{{ e.first }}</td>
|
||||||
<td>{{ e.last }}</td>
|
<td>{{ e.last }}</td>
|
||||||
<td>{{ e.position }}</td>
|
<td>{{ e.position }}</td>
|
||||||
<td>{{ e.status }}, {{ e.children }} children</td>
|
<td><a href="/staff/{{ e.id }}">Details</a></td>
|
||||||
<td>{{ e.hired }}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
19
templates/staff_detail.html
Normal file
19
templates/staff_detail.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{% 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>{{ employee.position }}</dd>
|
||||||
|
<dt>Marital Status</dt>
|
||||||
|
<dd>{{ employee.status }}</dd>
|
||||||
|
<dt>Number of Children</dt>
|
||||||
|
<dd>{{ employee.children }}</dd>
|
||||||
|
<dt>Hired</dt>
|
||||||
|
<dd>{{ employee.hired }}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user