Attendance/manage/student.py

39 lines
1.7 KiB
Python
Raw Normal View History

2021-12-26 05:08:50 -08:00
from functions import *
2021-12-27 06:34:19 -08:00
2021-12-26 05:08:50 -08:00
student = Blueprint('student', __name__)
2021-12-27 06:34:19 -08:00
2021-12-26 05:08:50 -08:00
@student.route('/student', methods=['GET'])
def showStudentAbs():
2021-12-27 06:34:19 -08:00
if check_login_status():
2021-12-26 05:08:50 -08:00
return redirect('/logout')
refresh_token()
if not ('user_type' in session and session['user_type'] == 'student'):
return redirect('/')
db = refresh_db()
cursor = db.cursor()
2021-12-27 06:34:19 -08:00
cursor.execute(
"SELECT date, period, num, status, note FROM absent WHERE grade=%s AND class_=%s AND num=%s ORDER BY date DESC, FIND_IN_SET(period, 'm,1,2,3,4,n,5,6,7,8,9') DESC, num ASC",
(session['grade'], session['class'], session['num']))
2021-12-26 05:08:50 -08:00
absentDataSQL = cursor.fetchall()
2021-12-27 06:34:19 -08:00
return render_template("list.html", title="Student Absent List | 學生缺勤紀錄", mode='STUDABS', data=absentDataSQL,
currRoom=[session['grade'], session['class']], name=session['name'], num=session['num'])
2021-12-26 05:08:50 -08:00
@student.route('/student/ds', methods=['GET'])
def showStudentDS():
2021-12-27 06:34:19 -08:00
if check_login_status():
2021-12-26 05:08:50 -08:00
return redirect('/logout')
refresh_token()
if not ('user_type' in session and session['user_type'] == 'student'):
return redirect('/')
db = refresh_db()
cursor = db.cursor()
2021-12-27 06:34:19 -08:00
cursor.execute(
"SELECT date, period, num, note FROM ds WHERE grade=%s AND class_=%s AND num=%s ORDER BY date DESC, FIND_IN_SET(period, 'm,1,2,3,4,n,5,6,7,8,9') DESC, num ASC",
(session['grade'], session['class'], session['num']))
2021-12-26 05:08:50 -08:00
dsDataSQL = cursor.fetchall()
print(dsDataSQL)
2021-12-27 06:34:19 -08:00
return render_template("list.html", title="Student DS List | 學生定心紀錄", mode='STUDDS', data=dsDataSQL,
currRoom=[session['grade'], session['class']], name=session['name'], num=session['num'])