Added manual swipe, swipe delete, cleanup, dark theme
This commit is contained in:
parent
67bc482155
commit
55be2a898b
4 changed files with 60 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
|||
body {
|
||||
font-family: Roboto, sans-serif;
|
||||
background-color: #242424;
|
||||
color: #fff;
|
||||
color: #A6A6A6;
|
||||
}
|
||||
|
||||
header {
|
||||
|
|
18
app/templates/log.html
Normal file
18
app/templates/log.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version = "1.0"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/main.css') }}" />
|
||||
<title>Log</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="log" method="POST"><input type="date" name="after_date" value="{{after_date}}" /><input type="submit" /></form>
|
||||
<form action="/log/modify" method="POST">
|
||||
{% for swipe in swipes %}
|
||||
<button type="submit" name="delete_id" value="{{swipe['id']}}">X</button>
|
||||
{{ swipe['time'] }} | {{ swipe['first_name'] | safe }} | {{ swipe['last_name'] | safe }} <br>
|
||||
{% endfor %}
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -20,6 +20,7 @@
|
|||
<option value='Student'>Student</option>
|
||||
<option value='Mentor'>Mentor</option>
|
||||
</select><br>
|
||||
<button type="submit", name="action", value="swipe">Swipe</button>
|
||||
<button type="submit", name="action", value="set_name">Change Name</button>
|
||||
<button type="submit", name="action", value="set_uid">Change ID</button>
|
||||
<button type="submit", name="action", value="new_user">New User</button>
|
||||
|
|
50
app/views.py
50
app/views.py
|
@ -8,6 +8,8 @@ from datetime import date
|
|||
import json
|
||||
# from flask_login import login_user, login_required, logout_user
|
||||
|
||||
after_date = '2024-08-22'
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return 'No.'
|
||||
|
@ -36,6 +38,10 @@ def users():
|
|||
@app.route('/users/modify', methods=['POST'])
|
||||
def users_modify():
|
||||
data = request.form
|
||||
if data['action'] == 'swipe':
|
||||
swipe = Swipe(data['uuid'])
|
||||
db.session.add(swipe)
|
||||
db.session.commit()
|
||||
if data['action'] == 'set_name':
|
||||
if data['first_name'] == '' or data['last_name'] == '':
|
||||
return 'Fill out the form...'
|
||||
|
@ -90,17 +96,38 @@ def swipe():
|
|||
|
||||
return 'OK'
|
||||
|
||||
@app.route('/log', methods=['GET'])
|
||||
@app.route('/log', methods=['GET', 'POST'])
|
||||
def log():
|
||||
swipes = db.session.query(Swipe)
|
||||
result = ''
|
||||
global after_date
|
||||
if request.method == 'POST':
|
||||
after_date = request.form['after_date']
|
||||
swipes = db.session.query(Swipe).filter(Swipe.time >= after_date)
|
||||
result = []
|
||||
for swipe in swipes:
|
||||
print(swipe.__dict__)
|
||||
first_name = 'WHO DIS'
|
||||
last_name = swipe.uuid
|
||||
|
||||
names = User.query.filter_by(uuid=swipe.uuid).first()
|
||||
if names:
|
||||
result += f'{swipe.time} | {names.first_name} | {names.last_name}<br>'
|
||||
else:
|
||||
result += f'{swipe.time} | WHO DIS {swipe.uuid}<br>'
|
||||
return result
|
||||
first_name = names.first_name
|
||||
last_name = names.last_name
|
||||
result.append({
|
||||
'time': swipe.time,
|
||||
'first_name': first_name,
|
||||
'last_name': last_name,
|
||||
'id': swipe.id})
|
||||
return render_template('log.html', swipes=result, after_date=after_date)
|
||||
|
||||
@app.route('/log/modify', methods=['POST'])
|
||||
def log_modify():
|
||||
data = request.form
|
||||
if 'delete_id' in data:
|
||||
swipe = Swipe.query.filter_by(id=data['delete_id']).first()
|
||||
db.session.delete(swipe)
|
||||
db.session.commit()
|
||||
|
||||
return redirect(url_for('log'), code=302)
|
||||
|
||||
@app.route('/kiosk', methods=['GET'])
|
||||
def kiosk():
|
||||
|
@ -108,7 +135,7 @@ def kiosk():
|
|||
|
||||
@app.route('/kiosk/data', methods=['GET'])
|
||||
def kiosk_data():
|
||||
swipes = db.session.query(Swipe).filter(Swipe.time >= '2023-07-16')
|
||||
swipes = db.session.query(Swipe).filter(Swipe.time >= after_date)
|
||||
|
||||
counts = {}
|
||||
last_swipes = {}
|
||||
|
@ -145,7 +172,7 @@ def kiosk_data():
|
|||
|
||||
@app.route('/report', methods=['GET', 'POST'])
|
||||
def report():
|
||||
after_date = '2024-08-22'
|
||||
global after_date
|
||||
if request.method == 'POST':
|
||||
after_date = request.form['after_date']
|
||||
days = {}
|
||||
|
@ -168,7 +195,8 @@ def report():
|
|||
|
||||
|
||||
|
||||
result = f'<form action="report" method="POST"><input type="date" name="after_date" value="{after_date}" /><input type="submit" /></form>'
|
||||
result = '<link rel="stylesheet" type="text/css" href="/static/css/main.css">'
|
||||
result += f'<form action="report" method="POST"><input type="date" name="after_date" value="{after_date}" /><input type="submit" /></form>'
|
||||
result += '<table border=1 style="table-layout:fixed;">'
|
||||
|
||||
name_query = db.session.query(User)
|
||||
|
@ -177,7 +205,7 @@ def report():
|
|||
for name_obj in name_query:
|
||||
name = f'{name_obj.first_name} {name_obj.last_name}'
|
||||
names.append(name)
|
||||
result += f'<th style="width: 100px; position: sticky; top: 0; background: white;">{name}</th>'
|
||||
result += f'<th style="width: 100px; position: sticky; top: 0;">{name}</th>'
|
||||
result += '</tr></thead>'
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue