Show clocked in users at the top of the page
This commit is contained in:
24
app.py
24
app.py
@@ -192,6 +192,27 @@ def index():
|
|||||||
ORDER BY name
|
ORDER BY name
|
||||||
""").fetchall()
|
""").fetchall()
|
||||||
|
|
||||||
|
|
||||||
|
# NEW: users currently clocked in
|
||||||
|
clocked_in_users = conn.execute("""
|
||||||
|
SELECT u.id, u.name
|
||||||
|
FROM users u
|
||||||
|
JOIN (
|
||||||
|
SELECT e.user_id, e.entrytype, e.ts
|
||||||
|
FROM entries e
|
||||||
|
INNER JOIN (
|
||||||
|
SELECT user_id, MAX(ts) AS max_ts
|
||||||
|
FROM entries
|
||||||
|
GROUP BY user_id
|
||||||
|
) latest
|
||||||
|
ON e.user_id = latest.user_id
|
||||||
|
AND e.ts = latest.max_ts
|
||||||
|
) last_entry
|
||||||
|
ON u.id = last_entry.user_id
|
||||||
|
WHERE last_entry.entrytype = 'in'
|
||||||
|
ORDER BY u.name
|
||||||
|
""").fetchall()
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
report_hours = None
|
report_hours = None
|
||||||
@@ -221,7 +242,8 @@ def index():
|
|||||||
return render_template(
|
return render_template(
|
||||||
"index.html",
|
"index.html",
|
||||||
users=users,
|
users=users,
|
||||||
report_hours=report_hours
|
report_hours=report_hours,
|
||||||
|
clocked_in_users=clocked_in_users
|
||||||
)
|
)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -8,6 +8,22 @@
|
|||||||
|
|
||||||
<h1>Simple Time Clock</h1>
|
<h1>Simple Time Clock</h1>
|
||||||
|
|
||||||
|
<h2>Currently Clocked In</h2>
|
||||||
|
|
||||||
|
{% if clocked_in_users %}
|
||||||
|
<ul>
|
||||||
|
{% for user in clocked_in_users %}
|
||||||
|
<li>{{ user.name }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No users are currently clocked in.</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<hr/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
|
|
||||||
<table border="1" cellpadding="5">
|
<table border="1" cellpadding="5">
|
||||||
@@ -19,7 +35,7 @@
|
|||||||
|
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<option value="{{ user.id }}">
|
<option value="{{ user.id }}">
|
||||||
{{ user.name }}
|
{{ user.name }}
|
||||||
</option>
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user