+
+
+ Log
+
+
+
+
+
+
diff --git a/app/templates/users.html b/app/templates/users.html
index f804bbf..d7a734d 100644
--- a/app/templates/users.html
+++ b/app/templates/users.html
@@ -20,6 +20,7 @@
+
diff --git a/app/views.py b/app/views.py
index 1cc7d43..4e45d7a 100644
--- a/app/views.py
+++ b/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} '
- else:
- result += f'{swipe.time} | WHO DIS {swipe.uuid} '
- 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''
+ result = ''
+ result += f''
result += '
'
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'