From 7550b896ce360a998da788beae4b4c6f734f473e Mon Sep 17 00:00:00 2001 From: Mitsuo Tokumori Date: Sun, 29 Oct 2023 18:47:23 -0500 Subject: Add filtering and pagination to bp.estudiantes --- README.md | 7 ++- ustayml/schema.sql | 23 ++++++--- ustayml/static/style.css | 73 +++++++++++++++++++++------- ustayml/templates/students/index.html | 83 +++++++++++++++++++------------- ustayml/views/students.py | 91 +++++++++++++++++++++++------------ 5 files changed, 187 insertions(+), 90 deletions(-) diff --git a/README.md b/README.md index 2dc8520..19baa71 100644 --- a/README.md +++ b/README.md @@ -74,4 +74,9 @@ Pros: Cons: * Maybe scalability and performance is lower compared to PHP or Javascript - web applications. \ No newline at end of file + web applications. + +## Next Steps + +* https://www.sqlalchemy.org/ +* https://stackoverflow.com/questions/10434599/get-the-data-received-in-a-flask-request \ No newline at end of file diff --git a/ustayml/schema.sql b/ustayml/schema.sql index 8062be8..e7e3e68 100644 --- a/ustayml/schema.sql +++ b/ustayml/schema.sql @@ -24,6 +24,11 @@ CREATE TABLE post ( -- Students +create table desertion_risk_class ( + id serial primary key, + "name" text +); + create table pucp_unit ( id serial primary key, "name" text @@ -58,9 +63,10 @@ CREATE TABLE student ( current_ppne3 REAL, current_merit REAL, est_study_length INTEGER, - est_dessertion_risk TEXT, + est_desertion_risk_class_id integer, FOREIGN KEY (administrative_division_id) REFERENCES administrative_division (id), - FOREIGN KEY (pucp_unit_id) REFERENCES pucp_unit (id) + FOREIGN KEY (pucp_unit_id) REFERENCES pucp_unit (id), + FOREIGN KEY (est_desertion_risk_class_id) REFERENCES desertion_risk_class (id) ); -- alter table student @@ -80,6 +86,11 @@ INSERT INTO "user" ("username","password","role_id") VALUES ('mitsuo','scrypt:32768:8:1$DNNf1Ah1SwUcFHIU$c0e40293c9ecff498b74e7727a8d9a348371262b85cc880e8c653438b1afa84849adb7230f4fcd995c82de543a7836a5cda2a411a45c17dc653e7036fe3de482',1) ; +INSERT INTO desertion_risk_class ("name") VALUES + ('Alto'), + ('Bajo'), + ('Medio'); + INSERT INTO pucp_unit ("name") VALUES ('Facultad de Ciencias e Ingenieria'), ('Estudios Generales Ciencias'); @@ -138,7 +149,7 @@ INSERT INTO public.administrative_division (country,subdivision1,subdivision2,su ('Peru','Lima','Lima','VILLA MARÍA DEL TRIUNFO ','Lima Sur','150143',404692,21.1,'district'); -INSERT INTO student (pucp_code,first_name,last_name,email,administrative_division_id,pucp_unit_id,tuition_bracket,current_semester,current_attendance,current_craest,current_ppne3,current_merit,est_study_length,est_dessertion_risk) VALUES - (20171234,'Alberto','Alvarez','aalvarez@pucp.edu.pe',40,1,'G5',5,0.8,58.35,55.23,0.1532,10,'L'), - (20171235,'Benito','Bueno','bbueno@pucp.edu.pe',41,2,'G5',5,0.8,58.35,55.23,0.1532,10,'H'), - (20171236,'Carlos','Canto','ccanto@pucp.edu.pe',42,1,'G5',5,0.8,58.35,55.23,0.1532,10,'L'); \ No newline at end of file +INSERT INTO student (pucp_code,first_name,last_name,email,administrative_division_id,pucp_unit_id,tuition_bracket,current_semester,current_attendance,current_craest,current_ppne3,current_merit,est_study_length,est_desertion_risk_class_id) VALUES + (20171234,'Alberto','Alvarez','aalvarez@pucp.edu.pe',40,1,'G5',5,0.8,58.35,55.23,0.1532,10,1), + (20171235,'Benito','Bueno','bbueno@pucp.edu.pe',41,2,'G5',5,0.8,58.35,55.23,0.1532,10,1), + (20171236,'Carlos','Canto','ccanto@pucp.edu.pe',42,1,'G5',5,0.8,58.35,55.23,0.1532,10,2); \ No newline at end of file diff --git a/ustayml/static/style.css b/ustayml/static/style.css index 08b5e9f..9246706 100644 --- a/ustayml/static/style.css +++ b/ustayml/static/style.css @@ -91,21 +91,6 @@ header .action { margin: 1rem 0 0.25rem 0; } -.content > .filters { - margin-top: 1em; - margin-bottom: 1em; -} - -.content .filters-list { - display: flex; - flex-direction: row; - align-items: flex-end; - /* justify-content: center; */ -} - -.filters-list select { - margin-right: 2em; -} .flash { margin: 1em 0; @@ -116,6 +101,8 @@ header .action { /* students */ +/* table */ + .students-table { padding: 2em; width: 100%; @@ -135,6 +122,56 @@ header .action { margin-top: 5em; } +.table-pagination { + display: flex; + flex-direction: row; + align-items: flex-end; +} + +.table-pagination > .page-list { + display:none; + /* flex:auto; */ + /* display: flex; */ + /* flex-direction: column; */ + /* align-items: flex-end; */ + justify-content: flex-end; + margin-right: 1em; +} + +.table-pagination > .page-list a { + margin-left: .2em +} + +.filter-criteria { + margin-top: 1em; + margin-bottom: 1em; +} + +.filter-criteria fieldset { + display: flex; + /* justify-content: space-between; */ + border: 0; + padding: 0; + align-items: flex-end; + justify-content: left; +} + +.filter-criteria label { + width: auto; + display: block; + font-size: small; +} + +/* .filter-criteria input { + position: absolute; + bottom: 0; + right: 0; +} */ + +.filters-list select { + margin-right: 2em; +} + /* post */ .post > header { @@ -171,12 +208,12 @@ header .action { flex-direction: column; } -.content label { +/* .content label { font-weight: bold; margin-bottom: 0.5em; -} +} */ -.content input, +/* .content input, */ .content textarea { margin-bottom: 1em; } diff --git a/ustayml/templates/students/index.html b/ustayml/templates/students/index.html index 74c1847..6fb5312 100644 --- a/ustayml/templates/students/index.html +++ b/ustayml/templates/students/index.html @@ -7,45 +7,58 @@ {% endblock %} {% block content %} -
- {#

Filtros

#} -
-