From f6fcf9cc3ae3d93d59391b3f12843fba3297f0b2 Mon Sep 17 00:00:00 2001 From: Mitsuo Tokumori Date: Sun, 12 Nov 2023 19:37:13 -0500 Subject: Add data and tooltips to student.details --- ustayml/views/students.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'ustayml/views/students.py') diff --git a/ustayml/views/students.py b/ustayml/views/students.py index ba1de04..6132746 100644 --- a/ustayml/views/students.py +++ b/ustayml/views/students.py @@ -5,7 +5,7 @@ from flask import ( from werkzeug.exceptions import abort from ustayml.views.auth import login_required -from ustayml.db import get_db, get_paginated_items +from ustayml.db import get_db, get_paginated_rows, get_row bp = Blueprint('students', __name__, url_prefix='/students') @@ -46,7 +46,7 @@ def index(): """ # output & formatting - students = get_paginated_items(query, params=params, pagination=pagination) + students = get_paginated_rows(query, params=params, pagination=pagination) for s in students: s['fullname'] = f"{s['first_name']} {s['last_name']}" s['current_attendance'] = f"{s['current_attendance']*100:.2f}%" @@ -61,12 +61,19 @@ def index(): fc=fc ) -@bp.route('/', methods=('GET', 'POST')) +@bp.route('/', methods=('GET', 'POST')) @login_required -def details(id): - db = get_db() - pucp_unit = db.execute("select * from view_student;").fetchall() +def details(student_id): + s = get_row("select * from view_student vs where vs.id = %s;", + [student_id] + ) + + s['fullname'] = f"{s['first_name']} {s['last_name']}" + s['current_attendance'] = f"{s['current_attendance'] * 100:.2f}%" + s['current_merit'] = f"{s['current_merit'] * 100:.2f}%" + return render_template( 'students/details.html', - date=datetime.datetime.now() + date=datetime.datetime.now(), + student=s ) \ No newline at end of file -- cgit v1.2.3