aboutsummaryrefslogtreecommitdiff
path: root/ustayml/views/students.py
diff options
context:
space:
mode:
authorMitsuo Tokumori <rtokumori@pucp.edu.pe>2023-11-12 19:37:13 -0500
committerMitsuo Tokumori <rtokumori@pucp.edu.pe>2023-11-12 19:37:13 -0500
commitf6fcf9cc3ae3d93d59391b3f12843fba3297f0b2 (patch)
tree289032ff9b133a9fe71e8a23355fdea10171bcf6 /ustayml/views/students.py
parentfcd9465d564b08ae289417fb0616942b38fd0836 (diff)
Add data and tooltips to student.details
Diffstat (limited to 'ustayml/views/students.py')
-rw-r--r--ustayml/views/students.py21
1 files changed, 14 insertions, 7 deletions
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('/<int:id>', methods=('GET', 'POST'))
+@bp.route('/<int:student_id>', 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