diff options
| -rw-r--r-- | ustayml/__init__.py | 24 | ||||
| -rw-r--r-- | ustayml/templates/auth/login.html | 8 | ||||
| -rw-r--r-- | ustayml/templates/auth/register.html | 10 | ||||
| -rw-r--r-- | ustayml/templates/base.html | 2 | ||||
| -rw-r--r-- | ustayml/templates/dashboard/index.html | 51 | ||||
| -rw-r--r-- | ustayml/templates/index.html | 15 | ||||
| -rw-r--r-- | ustayml/templates/load_data/index.html | 9 | ||||
| -rw-r--r-- | ustayml/templates/load_data/success.html | 2 | ||||
| -rw-r--r-- | ustayml/views/dashboard.py | 37 | ||||
| -rw-r--r-- | ustayml/views/load_data.py | 2 | ||||
| -rw-r--r-- | ustayml/views/students.py | 2 |
11 files changed, 133 insertions, 29 deletions
diff --git a/ustayml/__init__.py b/ustayml/__init__.py index fbe1b3a..9e57bc4 100644 --- a/ustayml/__init__.py +++ b/ustayml/__init__.py @@ -1,6 +1,6 @@ import os -from flask import Flask +from flask import Flask, render_template def create_app(test_config=None): @@ -25,24 +25,24 @@ def create_app(test_config=None): except OSError: pass - # Routes - @app.route('/hello') - def hello(): - return 'Hello, World!' - - # Register functions and blueprints from . import db db.init_app(app) - # from .views import blog - # app.register_blueprint(blog.bp) + # Register functions and blueprints - from .views import auth, students, load_data + @app.route('/') + def index(): + return render_template('index.html') + + from .views import ( + auth, + students, load_data, dashboard + ) app.register_blueprint(auth.bp) app.register_blueprint(students.bp) app.register_blueprint(load_data.bp) + app.register_blueprint(dashboard.bp) - # Extra - app.add_url_rule('/', endpoint='index') + # app.add_url_rule('/', endpoint='index') return app
\ No newline at end of file diff --git a/ustayml/templates/auth/login.html b/ustayml/templates/auth/login.html index 45acd7f..9560ba5 100644 --- a/ustayml/templates/auth/login.html +++ b/ustayml/templates/auth/login.html @@ -1,15 +1,15 @@ {% extends 'base.html' %} {% block header %} - <h1>{% block title %}Log In{% endblock %}</h1> + <h1>{% block title %}Ingresar{% endblock %}</h1> {% endblock %} {% block content %} <form class="simple-form" method="post"> - <label for="username">Username</label> + <label for="username">Usuario</label> <input name="username" id="username" required> - <label for="password">Password</label> + <label for="password">Contraseña</label> <input type="password" name="password" id="password" required> - <input type="submit" value="Log In"> + <input type="submit" value="Ingresar"> </form> {% endblock %}
\ No newline at end of file diff --git a/ustayml/templates/auth/register.html b/ustayml/templates/auth/register.html index a3c73cc..ef1264d 100644 --- a/ustayml/templates/auth/register.html +++ b/ustayml/templates/auth/register.html @@ -1,15 +1,15 @@ {% extends 'base.html' %} {% block header %} - <h1>{% block title %}Register{% endblock %}</h1> + <h1>{% block title %}Registrarse{% endblock %}</h1> {% endblock %} {% block content %} - <form method="post"> - <label for="username">Username</label> + <form class="simple-form" method="post"> + <label for="username">Usuario</label> <input name="username" id="username" required> - <label for="password">Password</label> + <label for="password">Contraseña</label> <input type="password" name="password" id="password" required> - <input type="submit" value="Register"> + <input type="submit" value="Registerse"> </form> {% endblock %}
\ No newline at end of file diff --git a/ustayml/templates/base.html b/ustayml/templates/base.html index eefbc06..580249a 100644 --- a/ustayml/templates/base.html +++ b/ustayml/templates/base.html @@ -5,7 +5,7 @@ <nav> <h1><a href="{{ url_for('index') }}">u-stayML</a></h1> <ul> - <li><a href="#">Dashboard</a></li> + <li><a href="{{ url_for('dashboard.index') }}">Dashboard</a></li> <li><a href="{{ url_for('students.index') }}">Estudiantes</a></li> <li><a href="#">Historial</a> </li> <li><a href="{{ url_for('load_data.index') }}">Cargar datos</a> </li> diff --git a/ustayml/templates/dashboard/index.html b/ustayml/templates/dashboard/index.html new file mode 100644 index 0000000..3117ec2 --- /dev/null +++ b/ustayml/templates/dashboard/index.html @@ -0,0 +1,51 @@ +{% extends 'base.html' %} + + +{% block header %} + <h1>{% block title %}Dashboard{% endblock %}</h1> +{% endblock %} + +{% block content %} + <div class="filter-criteria"> + <form class="filters" method="get"> + <fieldset class="filters-list"> + <div> + <label for="pucp_unit">Unidad:</label> + <select name="pucp_unit" id="pucp_unit"> + <option value="0">Mostrar todas</option> + {% for e in pucp_unit %} + <option value="{{e['id']}}" {% if e['id'] == fc['pucp_unit'] %} selected {% endif %}>{{ e['name'] }}</option> + {% endfor %} + </select> + </div> + <div> + <label for="semester">Semestre: </label> + <select name="semester" id="semester"> + <option value="0">Mostrar todos</option> + {% for e in semester %} + <option value="{{e['id']}}" {% if e['id'] == fc['semester'] %} selected {% endif %}>{{ e['name'] }}</option> + {% endfor %} + </select> + </div> + <div> + <label for="desertion_risk_class">Riesgo deserción: </label> + <select name="desertion_risk_class" id="desertion_risk_class"> + <option value="0">Mostrar todos</option> + {% for e in desertion_risk_class %} + <option value="{{e['id']}}" {% if e['id'] == fc['desertion_risk_class'] %} selected {% endif %}>{{ e['name'] }}</option> + {% endfor %} + </select> + </div> + <div> + <label></label> + <input type="submit" value="Aplicar filtros"> + </div> + </fieldset> + </form> + </div> + <div class="dashboard-graphics"> + <div class="chart"> + <img src="{{ url_for('static', filename='img/sample-bar_chart.png') }}"> + </div> + </div> +{% endblock %}
\ No newline at end of file diff --git a/ustayml/templates/index.html b/ustayml/templates/index.html new file mode 100644 index 0000000..b781a2c --- /dev/null +++ b/ustayml/templates/index.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} + + +{% block header %} + <h1>{% block title %}u-stayML{% endblock %}</h1> +{% endblock %} + +{% block content %} + <p>“u-stayML” es un sistema de información de predicción de deserción + estudiantil universitaria, permite identificar los principales factores de + deserción estudiantil universitaria, y facilitar a los asesores académicos en + su tarea de ayudar a los estudiantes en riesgo de una manera más practiva y + ágil.</p> + <p>Por favor, seleccione un link de la parte superior para comenzar.</p> +{% endblock %} diff --git a/ustayml/templates/load_data/index.html b/ustayml/templates/load_data/index.html index 3400de3..fb5088e 100644 --- a/ustayml/templates/load_data/index.html +++ b/ustayml/templates/load_data/index.html @@ -23,7 +23,7 @@ <ul class="data-validation-list"> <li>Tipo de archivo debe ser CSV</li> <li>Tamaño debe ser <1 MiB</li> - <li>Debe existir la variable "target"</li> + <li>Debe existir la variable <code>Target</code></li> </ul> </div> </div> @@ -51,10 +51,11 @@ <div class="flex-container-horizontal"> <div class="left"> <p>El diccionario de variables lista información sobre las variables del dataset.</p> - <label for="dataset-label">Etiqueta: </label> - <input name="dataset-label" id="dataset-label" required> + <label for="dataset-label">Etiqueta*: </label> + <input name="dataset-label" id="dataset-label" required + placeholder="2023-1 EEGGCC FCI"> <p></p> - <label for="dataset-date">Fecha del conjunto de datos: </label> + <label for="dataset-date">Fecha del conjunto de datos*: </label> <input name="dataset-date" id="dataset-date" required type="date"> <div></div> diff --git a/ustayml/templates/load_data/success.html b/ustayml/templates/load_data/success.html index 442ef74..956c186 100644 --- a/ustayml/templates/load_data/success.html +++ b/ustayml/templates/load_data/success.html @@ -12,5 +12,5 @@ de riesgo de deserción.</p> <p>Podrá validar que el procesamiento terminó verificando la fecha del reporte.</p> - <a href="{{ url_for('index') }}">Regresar al dashboard</a> + <a href="{{ url_for('dashboard.index') }}">Regresar al dashboard</a> {% endblock %}
\ No newline at end of file diff --git a/ustayml/views/dashboard.py b/ustayml/views/dashboard.py index e69de29..0295c30 100644 --- a/ustayml/views/dashboard.py +++ b/ustayml/views/dashboard.py @@ -0,0 +1,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') + [email protected]('/', 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' + ) diff --git a/ustayml/views/load_data.py b/ustayml/views/load_data.py index e57f40c..20833c2 100644 --- a/ustayml/views/load_data.py +++ b/ustayml/views/load_data.py @@ -25,7 +25,7 @@ def index(): # If the user does not select a file, the browser submits an # empty file without a filename. if file.filename == '': - flash('No selected file') + flash('Por favor, suba el diccionario de variables') return redirect(request.url) if file and allowed_file(file.filename): filename = secure_filename(file.filename) diff --git a/ustayml/views/students.py b/ustayml/views/students.py index 3b31790..c3ad563 100644 --- a/ustayml/views/students.py +++ b/ustayml/views/students.py @@ -77,6 +77,6 @@ def details(student_id): return render_template( 'students/details.html', - date=datetime.datetime.now(), + date=datetime.datetime(2023, 10, 26), student=s )
\ No newline at end of file |
