aboutsummaryrefslogtreecommitdiff
path: root/ustayml/views/dashboard.py
blob: 0295c30ab2de141edd80649d348f896cc3a56d2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import datetime
from flask import (
    Blueprint, flash, g, redirect, render_template, request, url_for
)
from werkzeug.exceptions import abort

from ustayml.views.auth import login_required
from ustayml.db import get_db, get_paginated_rows, get_row

bp = Blueprint('dashboard', __name__, url_prefix='/dashboard')

@bp.route('/', methods=('GET', 'POST'))
@login_required
def index():
    db = get_db()
    pucp_unit = db.execute("select * from pucp_unit;").fetchall()
    semester = [{'id': x, 'name': x} for x in range(1, 13)]
    desertion_risks_class = db.execute("select * from desertion_risk_class;").fetchall()

    # filter criteria    | field choices
    fc = {
        'pucp_unit': int(request.args.get('pucp_unit', 0)),
        'semester': int(request.args.get('semester', 0)),
        'desertion_risk_class': int(request.args.get('desertion_risk_class', 0)),
    }

    return render_template(
        'dashboard/index.html', 
        # students=students, pagination=pagination,
        pucp_unit=pucp_unit,
        semester=semester,
        desertion_risk_class=desertion_risks_class,
        fc=fc
    )
    return render_template(
        'dashboard/index.html'
    )