From 4a7be6c221f2357d194bb3eb59648d609b61c1e6 Mon Sep 17 00:00:00 2001 From: georgievh Date: Tue, 30 Jun 2026 18:45:26 +0000 Subject: [PATCH 01/72] edited supervisorDepartment --- app/models/supervisorDepartment.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/supervisorDepartment.py b/app/models/supervisorDepartment.py index 3585e1eb2..059712cc0 100644 --- a/app/models/supervisorDepartment.py +++ b/app/models/supervisorDepartment.py @@ -5,3 +5,4 @@ class SupervisorDepartment(baseModel): supervisor = ForeignKeyField(Supervisor, null=True) department = ForeignKeyField(Department) + banStatus = From 12d8d41764fd03ddc59c8421d63a770ac17f235f Mon Sep 17 00:00:00 2001 From: georgievh Date: Tue, 30 Jun 2026 18:45:55 +0000 Subject: [PATCH 02/72] edited supervisorDepartment --- app/models/supervisorDepartment.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/supervisorDepartment.py b/app/models/supervisorDepartment.py index 059712cc0..72a80ea6d 100644 --- a/app/models/supervisorDepartment.py +++ b/app/models/supervisorDepartment.py @@ -5,4 +5,12 @@ class SupervisorDepartment(baseModel): supervisor = ForeignKeyField(Supervisor, null=True) department = ForeignKeyField(Department) - banStatus = + banStatus = BooleanField(default=False) + isActive = BooleanField(default=False) + isCoordinator = BooleanField(default=False) + + @property + def isBanned(self): + return self.banStatus + + From a8684550b6260b90bf55507dda69b96868847796 Mon Sep 17 00:00:00 2001 From: feitsopb Date: Tue, 30 Jun 2026 19:15:25 +0000 Subject: [PATCH 03/72] added the position history file --- app/models/positionHistory.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/models/positionHistory.py diff --git a/app/models/positionHistory.py b/app/models/positionHistory.py new file mode 100644 index 000000000..f255dfbcb --- /dev/null +++ b/app/models/positionHistory.py @@ -0,0 +1,10 @@ +from app.models import * +from app.models.department import Department + +class PositionHistory(baseModel): + positioncode = PrimaryKeyField() + status = CharField() + WLS = IntegerField() + revisiondate = DateField() + Description = TextField() + Department = ForeignKeyField(Department) From 83c8c92e2fa28e5be183c8f09da4f8cdca317170 Mon Sep 17 00:00:00 2001 From: lolongaj Date: Tue, 30 Jun 2026 19:33:08 +0000 Subject: [PATCH 04/72] added the allocation model --- app/models/allocation.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/models/allocation.py diff --git a/app/models/allocation.py b/app/models/allocation.py new file mode 100644 index 000000000..ddd2084d7 --- /dev/null +++ b/app/models/allocation.py @@ -0,0 +1,19 @@ +from app.models import * +from app.models.department import Department +from app.models.supervisor import Supervisor +from app.models.term import Term + +class Allocation(baseModel): + termCode = ForeignKeyField(Term) + department = ForeignKeyField(Department) + isApproved = BooleanField(default=False) + approvedOn = DateField() + approvedBy = ForeignKeyField(Supervisor) + justification = TextField() + primary_10 = IntegerField() + primary_12 = IntegerField() + primary_15 = IntegerField() + primary_20 = IntegerField() + secondary_5 = IntegerField() + secondary_10 = IntegerField() + breakHours = IntegerField() From caad7d3733365f898f5031131bbdb07a8867e073 Mon Sep 17 00:00:00 2001 From: nahom70 Date: Tue, 30 Jun 2026 21:03:46 +0000 Subject: [PATCH 05/72] Added dummy data: weren't able to check if they work though --- database/demo_data.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/database/demo_data.py b/database/demo_data.py index 0557c9361..2d3ad1bdc 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -17,6 +17,8 @@ from app.models.laborStatusForm import LaborStatusForm from app.models.formHistory import FormHistory from app.models.notes import Notes +from app.models.positionHistory import PositionHistory # type: ignore + print("Inserting data for demo and testing purposes") @@ -609,3 +611,29 @@ ] Notes.insert_many(notes).on_conflict_replace().execute() print(" * laborOfficeNotes added") + + + +############################# +# Position History +############################# + +positionHistory = [ + { + "positioncode": 1, + "status": "Active", + "WLS":3, + "revisiondate" : "2020-01-01", + "Description": "This is a test data for position history code 1", + "Department" : "ACCT" + }, + { + "positioncode": 2, + "status": "Inactive", + "WLS":2, + "revisiondate" : "2023-01-01", + "Description": "This is a test data for position history code 2", + "Department" : "Computer Science" + }, +] +PositionHistory.insert_many(positionHistory).on_conflict_replace().execute() \ No newline at end of file From bea1a8c637863aa3720463af7f7180eaec488f34 Mon Sep 17 00:00:00 2001 From: Dayton Conwell Date: Tue, 30 Jun 2026 21:29:41 +0000 Subject: [PATCH 06/72] changed migrate_db.sh data to add PositionHistory, and added dummy data to demo_data.py --- database/demo_data.py | 13 +++++++++++++ database/migrate_db.sh | 1 + 2 files changed, 14 insertions(+) diff --git a/database/demo_data.py b/database/demo_data.py index 0557c9361..e55edb130 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -17,6 +17,9 @@ from app.models.laborStatusForm import LaborStatusForm from app.models.formHistory import FormHistory from app.models.notes import Notes +from app.models.allocation import Allocation +from app.models.positionHistory import PositionHistory +from app.models.supervisorDepartment import SupervisorDepartment print("Inserting data for demo and testing purposes") @@ -609,3 +612,13 @@ ] Notes.insert_many(notes).on_conflict_replace().execute() print(" * laborOfficeNotes added") +print(PositionHistory()) + +PositionHistory.insert([{ + "positioncode": "S61407", + "status": "Active", + "WLS": 1, + "revisiondate": f"{current_year}-04-01", + "Description": "Student Programmer", + "Department_id": 1 +}]).on_conflict_replace().execute() diff --git a/database/migrate_db.sh b/database/migrate_db.sh index f88c91f26..83f68a048 100755 --- a/database/migrate_db.sh +++ b/database/migrate_db.sh @@ -30,6 +30,7 @@ pem add app.models.supervisor.Supervisor pem add app.models.supervisorDepartment.SupervisorDepartment pem add app.models.studentLaborEvaluation.StudentLaborEvaluation pem add app.models.formSearchResult.FormSearchResult +pem add app.models.positionHistory.PositionHistory pem watch pem migrate From 2978b55ea3d277fc3a75e1a2ea12d7d58968a95f Mon Sep 17 00:00:00 2001 From: lolongaj Date: Tue, 30 Jun 2026 21:29:46 +0000 Subject: [PATCH 07/72] allocation table added --- database/demo_data.py | 22 ++++++++++++++++++++++ database/migrate_db.sh | 1 + 2 files changed, 23 insertions(+) diff --git a/database/demo_data.py b/database/demo_data.py index 0557c9361..34c80a3f5 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -17,6 +17,8 @@ from app.models.laborStatusForm import LaborStatusForm from app.models.formHistory import FormHistory from app.models.notes import Notes +from app.models.allocation import Allocation + print("Inserting data for demo and testing purposes") @@ -609,3 +611,23 @@ ] Notes.insert_many(notes).on_conflict_replace().execute() print(" * laborOfficeNotes added") + +allocation =[ + { + "termCode":f"{current_year}00", + "department": 3, + "isApproved": True, + "approvedOn": f"{current_year}-06-30", + "approvedBy": "B12365892", + "justification": "We just want it for fun", + "primary_10": 2, + "primary_12": 3, + "primary_15": 1, + "primary_20": 6, + "secondary_5": 2, + "secondary_10": 0, + "breakHours": 500 + } + ] +Allocation.insert_many(allocation).on_conflict_replace().execute() +print(" * allocation added") \ No newline at end of file diff --git a/database/migrate_db.sh b/database/migrate_db.sh index f88c91f26..5788fbead 100755 --- a/database/migrate_db.sh +++ b/database/migrate_db.sh @@ -30,6 +30,7 @@ pem add app.models.supervisor.Supervisor pem add app.models.supervisorDepartment.SupervisorDepartment pem add app.models.studentLaborEvaluation.StudentLaborEvaluation pem add app.models.formSearchResult.FormSearchResult +pem add app.models.allocation.Allocation pem watch pem migrate From 912f50f9fff9bdeea403b32c7a6abb34863f1122 Mon Sep 17 00:00:00 2001 From: georgievh Date: Tue, 30 Jun 2026 21:30:09 +0000 Subject: [PATCH 08/72] dummy allocations added --- database/demo_data.py | 123 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/database/demo_data.py b/database/demo_data.py index 0557c9361..d5eef179a 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -17,6 +17,10 @@ from app.models.laborStatusForm import LaborStatusForm from app.models.formHistory import FormHistory from app.models.notes import Notes +from app.models.allocation import Allocation +from app.models.positionHistory import PositionHistory +from app.models.supervisorDepartment import SupervisorDepartment + print("Inserting data for demo and testing purposes") @@ -515,6 +519,42 @@ "primaryCutOff": f"{current_year}-09-01", "adjustmentCutOff": f"{current_year}-09-01", }, + { + "termCode": f"{current_year-1}00", + "termName": f"AY {current_year-1}-{current_year}", + "termStart": f"{current_year-1}-08-01", + "termEnd": f"{current_year}-05-01", + "termState": 1, + "primaryCutOff": f"{current_year-1}-09-01", + "adjustmentCutOff": f"{current_year-1}-09-01", + }, + { + "termCode": f"{current_year-2}00", + "termName": f"AY {current_year-2}-{current_year-1}", + "termStart": f"{current_year-2}-08-01", + "termEnd": f"{current_year-1}-05-01", + "termState": 1, + "primaryCutOff": f"{current_year-2}-09-01", + "adjustmentCutOff": f"{current_year-2}-09-01", + }, + { + "termCode": f"{current_year-3}00", + "termName": f"AY {current_year-3}-{current_year-2}", + "termStart": f"{current_year-3}-08-01", + "termEnd": f"{current_year-2}-05-01", + "termState": 1, + "primaryCutOff": f"{current_year-3}-09-01", + "adjustmentCutOff": f"{current_year-3}-09-01", + }, + { + "termCode": f"{current_year-4}00", + "termName": f"AY {current_year-4}-{current_year-3}", + "termStart": f"{current_year-4}-08-01", + "termEnd": f"{current_year-3}-05-01", + "termState": 1, + "primaryCutOff": f"{current_year-4}-09-01", + "adjustmentCutOff": f"{current_year-4}-09-01", + }, { "termCode": f"{current_year}01", "termName": f"Thanksgiving Break {current_year}", @@ -609,3 +649,86 @@ ] Notes.insert_many(notes).on_conflict_replace().execute() print(" * laborOfficeNotes added") + +############################ +# Allocation Dummy Data: +########################### +allocations = [ + { + "termCode": 202200, + "department": "Computer Science", + "isApproved": True, + "approvedOn": None, + "approvedBy": None, + "justification": "Downscaling due to decrease in student enrollment caused by current economic conditions", + "primary_10": 2, + "primary_12": 2, + "primary_15": 1, + "primary_20": 0, + "secondary_5": 1, + "secondary_10": 0, + "breakHours": 260, + }, + { + "termCode": 202300, + "department": "ETAD", + "isApproved": True, + "approvedOn": None, + "approvedBy": None, + "justification": "Increase in student enrollment due to exodous from CS department", + "primary_10": 4, + "primary_15": 7, + "primary_20": 4, + "secondary_5": 2, + "secondary_10": 0, + "breakHours": 750, + }, + { + "termCode": 202400, + "department": "Mathematics", + "isApproved": True, + "approvedOn": None, + "approvedBy": None, + "justification": "We are hiring more students to help with the increased workload in the department", + "primary_10": 5, + "primary_12": 6, + "primary_15": 4, + "primary_20": 1, + "secondary_5": 7, + "secondary_10": 0, + "breakHours": 550, + }, + { + "termCode": 202500, + "department": "Physics", + "isApproved": True, + "approvedOn": None, + "approvedBy": None, + "justification": "Downscaling the number of students in the department due to budget cuts", + "primary_10": 4, + "primary_12": 5, + "primary_15": 0, + "primary_20": 0, + "secondary_5": 1, + "secondary_10": 0, + "breakHours": 300, + }, + { + "termCode": 202600, + "department": "Engineering Physics", + "isApproved": False, + "approvedOn": None, + "approvedBy": None, + "justification": "Due to rapid department growth, we need to hire more students to help with the increased workload", + "primary_10": 8, + "primary_12": 10, + "primary_15": 7, + "primary_20": 4, + "secondary_5": 5, + "secondary_10": 1, + "breakHours": 900, + }, + + ] + +print("Data insertion complete. Check phpmyadmin to see if your changes are reflected") \ No newline at end of file From a61ff1d4cd6a8462dcf36b7743d3ceddeee0d46b Mon Sep 17 00:00:00 2001 From: ArtemKurasov Date: Tue, 30 Jun 2026 21:34:25 +0000 Subject: [PATCH 09/72] Successfully added dummy data for the SupervisorDepartment class --- database/demo_data.py | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/database/demo_data.py b/database/demo_data.py index 0557c9361..ed5c07c82 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -17,6 +17,7 @@ from app.models.laborStatusForm import LaborStatusForm from app.models.formHistory import FormHistory from app.models.notes import Notes +from app.models.supervisorDepartment import SupervisorDepartment print("Inserting data for demo and testing purposes") @@ -609,3 +610,54 @@ ] Notes.insert_many(notes).on_conflict_replace().execute() print(" * laborOfficeNotes added") + + + +############################## +# Departement Members +############################## + +department_members = [ + { + "supervisor": "B12361006", + "department": 1, + "banStatus": False, + "isActive": True, + "isCoordinator": True + }, + + { + "supervisor": "B12365892", + "department": 1, + "banStatus": True, + "isActive": True, + "isCoordinator": False + }, + + { + "supervisor": "B12365893", + "department": 1, + "banStatus": False, + "isActive": False, + "isCoordinator": False + }, + + { + "supervisor": "B00763721", + "department": 1, + "banStatus": False, + "isActive": True, + "isCoordinator": False + }, + + { + "supervisor": "B00841417", + "department": 1, + "banStatus": False, + "isActive": True, + "isCoordinator": True + } +] + +SupervisorDepartment.insert_many(department_members).on_conflict_replace().execute() +print(" * Department members added") \ No newline at end of file From cebf62e554b0563ec48d64b3ec824a8e4b0d49e8 Mon Sep 17 00:00:00 2001 From: BhushanSah Date: Wed, 1 Jul 2026 13:24:38 +0000 Subject: [PATCH 10/72] Inserted the demo data --- database/demo_data.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/database/demo_data.py b/database/demo_data.py index d5eef179a..a4296412e 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -658,8 +658,8 @@ "termCode": 202200, "department": "Computer Science", "isApproved": True, - "approvedOn": None, - "approvedBy": None, + "approvedOn": 2021-10-19, + "approvedBy": "Dr heggen", "justification": "Downscaling due to decrease in student enrollment caused by current economic conditions", "primary_10": 2, "primary_12": 2, @@ -673,8 +673,8 @@ "termCode": 202300, "department": "ETAD", "isApproved": True, - "approvedOn": None, - "approvedBy": None, + "approvedOn": 2022-11-12, + "approvedBy": "Dr Jan", "justification": "Increase in student enrollment due to exodous from CS department", "primary_10": 4, "primary_15": 7, @@ -687,8 +687,8 @@ "termCode": 202400, "department": "Mathematics", "isApproved": True, - "approvedOn": None, - "approvedBy": None, + "approvedOn": 2023-12-19, + "approvedBy": "Dr Barnard", "justification": "We are hiring more students to help with the increased workload in the department", "primary_10": 5, "primary_12": 6, @@ -702,8 +702,8 @@ "termCode": 202500, "department": "Physics", "isApproved": True, - "approvedOn": None, - "approvedBy": None, + "approvedOn": 2025-1-10, + "approvedBy": "Dr Hodge", "justification": "Downscaling the number of students in the department due to budget cuts", "primary_10": 4, "primary_12": 5, @@ -717,8 +717,8 @@ "termCode": 202600, "department": "Engineering Physics", "isApproved": False, - "approvedOn": None, - "approvedBy": None, + "approvedOn": 2025-10-19, + "approvedBy": "Dr wu", "justification": "Due to rapid department growth, we need to hire more students to help with the increased workload", "primary_10": 8, "primary_12": 10, @@ -730,5 +730,6 @@ }, ] +Allocation.insert_many(allocations).on_conflict_replace().execute() -print("Data insertion complete. Check phpmyadmin to see if your changes are reflected") \ No newline at end of file +print("Data insertion complete :)") \ No newline at end of file From 539efdee27ba153c9e1ab5d09a62fbe60a1b9af0 Mon Sep 17 00:00:00 2001 From: fritzj2 Date: Wed, 1 Jul 2026 13:54:36 +0000 Subject: [PATCH 11/72] added a second round of demo data to the allocation --- database/demo_data.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/database/demo_data.py b/database/demo_data.py index 34c80a3f5..e3efef141 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -627,6 +627,21 @@ "secondary_5": 2, "secondary_10": 0, "breakHours": 500 + }, + { + "termCode":f"{current_year}00", + "department": 2, + "isApproved": False, + "approvedOn": f"{current_year}-06-20", + "approvedBy": "B00763721", + "justification": "We need it to lower the amount of allocations we have", + "primary_10": 1, + "primary_12": 2, + "primary_15": 5, + "primary_20": 2, + "secondary_5": 10, + "secondary_10": 0, + "breakHours": 1500 } ] Allocation.insert_many(allocation).on_conflict_replace().execute() From 6d58afdb3e687d532338231d09c4fc3b576c3fff Mon Sep 17 00:00:00 2001 From: Automation Date: Wed, 1 Jul 2026 13:56:19 +0000 Subject: [PATCH 12/72] We added more data for position history --- database/demo_data.py | 14 +++++++------- database/migrate_db.sh | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/database/demo_data.py b/database/demo_data.py index 2d3ad1bdc..90eb44817 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -17,8 +17,7 @@ from app.models.laborStatusForm import LaborStatusForm from app.models.formHistory import FormHistory from app.models.notes import Notes -from app.models.positionHistory import PositionHistory # type: ignore - +from app.models.positionHistory import PositionHistory print("Inserting data for demo and testing purposes") @@ -623,17 +622,18 @@ "positioncode": 1, "status": "Active", "WLS":3, - "revisiondate" : "2020-01-01", + "revisiondate" : f"{current_year}-01-01", "Description": "This is a test data for position history code 1", - "Department" : "ACCT" + "Department_id" : 2 + }, { "positioncode": 2, "status": "Inactive", "WLS":2, - "revisiondate" : "2023-01-01", + "revisiondate" : f"{current_year}-01-01", "Description": "This is a test data for position history code 2", - "Department" : "Computer Science" + "Department_id" : 1 }, ] -PositionHistory.insert_many(positionHistory).on_conflict_replace().execute() \ No newline at end of file +PositionHistory.insert_many(positionHistory).on_conflict_replace().execute() diff --git a/database/migrate_db.sh b/database/migrate_db.sh index f88c91f26..83f68a048 100755 --- a/database/migrate_db.sh +++ b/database/migrate_db.sh @@ -30,6 +30,7 @@ pem add app.models.supervisor.Supervisor pem add app.models.supervisorDepartment.SupervisorDepartment pem add app.models.studentLaborEvaluation.StudentLaborEvaluation pem add app.models.formSearchResult.FormSearchResult +pem add app.models.positionHistory.PositionHistory pem watch pem migrate From e670c2f37ecad6d092fa6dccde44fb2b928cefcb Mon Sep 17 00:00:00 2001 From: Dayton Conwell Date: Wed, 1 Jul 2026 14:22:52 +0000 Subject: [PATCH 13/72] fixed the demo_data to make it easier to merge, and fixed the positionhistory info to change the primary key field so position code shows --- app/models/positionHistory.py | 5 +++-- database/demo_data.py | 36 +++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/app/models/positionHistory.py b/app/models/positionHistory.py index f255dfbcb..222441787 100644 --- a/app/models/positionHistory.py +++ b/app/models/positionHistory.py @@ -2,9 +2,10 @@ from app.models.department import Department class PositionHistory(baseModel): - positioncode = PrimaryKeyField() + positionID = PrimaryKeyField() + positioncode = CharField() status = CharField() WLS = IntegerField() revisiondate = DateField() - Description = TextField() + Description = TextField(default=None) Department = ForeignKeyField(Department) diff --git a/database/demo_data.py b/database/demo_data.py index e55edb130..4b27ff3e3 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -614,11 +614,31 @@ print(" * laborOfficeNotes added") print(PositionHistory()) -PositionHistory.insert([{ - "positioncode": "S61407", - "status": "Active", - "WLS": 1, - "revisiondate": f"{current_year}-04-01", - "Description": "Student Programmer", - "Department_id": 1 -}]).on_conflict_replace().execute() +PositionHistory.insert = [ + { + "positioncode": "S61407", + "status": "Active", + "WLS": 1, + "revisiondate": f"{current_year}-07-01", + "Description": "", + "Department_id": 1 + }, + { + + "positioncode": "S61408", + "status": "Active", + "WLS": 2, + "revisiondate": f"{current_year}-07-01", + "Description": "", + "Department_id": 1 + }, + { + "positioncode": "S61409", + "status": "Active", + "WLS": 3, + "revisiondate": f"{current_year}-07-01", + "Description": "", + "Department_id": 1 + } +] +positionHistory = PositionHistory.insert_many(PositionHistory.insert).on_conflict_replace().execute() \ No newline at end of file From 4c3f8758df9e36e2ebbeba0dbd9a8cae7095d4ca Mon Sep 17 00:00:00 2001 From: Dayton Conwell Date: Wed, 1 Jul 2026 14:40:50 +0000 Subject: [PATCH 14/72] fixed demo data to fit pre existing format --- database/demo_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/demo_data.py b/database/demo_data.py index 4b27ff3e3..236f6444d 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -614,7 +614,7 @@ print(" * laborOfficeNotes added") print(PositionHistory()) -PositionHistory.insert = [ +positionhistory = [ { "positioncode": "S61407", "status": "Active", @@ -641,4 +641,4 @@ "Department_id": 1 } ] -positionHistory = PositionHistory.insert_many(PositionHistory.insert).on_conflict_replace().execute() \ No newline at end of file +PositionHistory.insert_many(positionhistory).on_conflict_replace().execute() \ No newline at end of file From 6666512ca20c6a7ea222faed977671ffcc9240a7 Mon Sep 17 00:00:00 2001 From: Automation Date: Wed, 1 Jul 2026 14:44:59 +0000 Subject: [PATCH 15/72] fixed formating --- app/models/positionHistory.py | 5 +++-- database/demo_data.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/models/positionHistory.py b/app/models/positionHistory.py index f255dfbcb..3fc1bd318 100644 --- a/app/models/positionHistory.py +++ b/app/models/positionHistory.py @@ -2,9 +2,10 @@ from app.models.department import Department class PositionHistory(baseModel): - positioncode = PrimaryKeyField() + positionID = PrimaryKeyField() + positioncode = CharField() status = CharField() WLS = IntegerField() revisiondate = DateField() - Description = TextField() + Description = TextField(default="None") Department = ForeignKeyField(Department) diff --git a/database/demo_data.py b/database/demo_data.py index 90eb44817..a6a316ae2 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -610,16 +610,16 @@ ] Notes.insert_many(notes).on_conflict_replace().execute() print(" * laborOfficeNotes added") - +print(PositionHistory()) ############################# # Position History ############################# -positionHistory = [ +positionhistory= [ { - "positioncode": 1, + "positioncode": "s6gjshs", "status": "Active", "WLS":3, "revisiondate" : f"{current_year}-01-01", @@ -636,4 +636,4 @@ "Department_id" : 1 }, ] -PositionHistory.insert_many(positionHistory).on_conflict_replace().execute() +PositionHistory.insert_many(positionhistory).on_conflict_replace().execute() From 0d517a961af1965f9cbd73f454c9cfad9236d93a Mon Sep 17 00:00:00 2001 From: Automation Date: Wed, 1 Jul 2026 14:47:13 +0000 Subject: [PATCH 16/72] fixed formating again --- app/models/positionHistory.py | 2 +- database/demo_data.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/positionHistory.py b/app/models/positionHistory.py index 3fc1bd318..222441787 100644 --- a/app/models/positionHistory.py +++ b/app/models/positionHistory.py @@ -7,5 +7,5 @@ class PositionHistory(baseModel): status = CharField() WLS = IntegerField() revisiondate = DateField() - Description = TextField(default="None") + Description = TextField(default=None) Department = ForeignKeyField(Department) diff --git a/database/demo_data.py b/database/demo_data.py index a6a316ae2..5269c53de 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -17,7 +17,10 @@ from app.models.laborStatusForm import LaborStatusForm from app.models.formHistory import FormHistory from app.models.notes import Notes -from app.models.positionHistory import PositionHistory +from app.models.positionHistory import PositionHistory +from app.models.allocation import Allocation +from app.models.positionHistory import PositionHistory +from app.models.supervisorDepartment import SupervisorDepartment print("Inserting data for demo and testing purposes") From e5869bbdfa0285fc26844afef2f69d3d4e84d72f Mon Sep 17 00:00:00 2001 From: Automation Date: Wed, 1 Jul 2026 14:49:48 +0000 Subject: [PATCH 17/72] fixed merge conflict --- database/demo_data.py | 61 ++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/database/demo_data.py b/database/demo_data.py index 5269c53de..1643d2447 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -620,23 +620,48 @@ # Position History ############################# -positionhistory= [ - { - "positioncode": "s6gjshs", - "status": "Active", - "WLS":3, - "revisiondate" : f"{current_year}-01-01", - "Description": "This is a test data for position history code 1", - "Department_id" : 2 +positionhistory = [ + { + "positioncode": "S61407", + "status": "Active", + "WLS": 1, + "revisiondate": f"{current_year}-07-01", + "Description": "", + "Department_id": 1 + }, + { + + "positioncode": "S61408", + "status": "Active", + "WLS": 2, + "revisiondate": f"{current_year}-07-01", + "Description": "", + "Department_id": 1 + }, + { + "positioncode": "S61409", + "status": "Active", + "WLS": 3, + "revisiondate": f"{current_year}-07-01", + "Description": "", + "Department_id": 1 + }, + { + "positioncode": "S61411", + "status": "Active", + "WLS":3, + "revisiondate" : f"{current_year}-01-01", + "Description": "This is a test data for position history code 1", + "Department_id" : 2 - }, - { - "positioncode": 2, - "status": "Inactive", - "WLS":2, - "revisiondate" : f"{current_year}-01-01", - "Description": "This is a test data for position history code 2", - "Department_id" : 1 - }, + }, + { + "positioncode": "S61410", + "status": "Inactive", + "WLS":2, + "revisiondate" : f"{current_year}-01-01", + "Description": "This is a test data for position history code 2", + "Department_id" : 1 + }, ] -PositionHistory.insert_many(positionhistory).on_conflict_replace().execute() +PositionHistory.insert_many(positionhistory).on_conflict_replace().execute() \ No newline at end of file From 49b5eac7080607a956abab4e65419da045cbc964 Mon Sep 17 00:00:00 2001 From: BhushanSah Date: Wed, 1 Jul 2026 14:55:29 +0000 Subject: [PATCH 18/72] Modified allocation --- app/models/allocation.py | 4 ++-- database/demo_data.py | 45 ++++++++++++++++++++-------------------- database/migrate_db.sh | 1 + 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/app/models/allocation.py b/app/models/allocation.py index ddd2084d7..75f9c828f 100644 --- a/app/models/allocation.py +++ b/app/models/allocation.py @@ -7,8 +7,8 @@ class Allocation(baseModel): termCode = ForeignKeyField(Term) department = ForeignKeyField(Department) isApproved = BooleanField(default=False) - approvedOn = DateField() - approvedBy = ForeignKeyField(Supervisor) + approvedOn = DateField(null =True) + approvedBy = ForeignKeyField(Supervisor, null =True) justification = TextField() primary_10 = IntegerField() primary_12 = IntegerField() diff --git a/database/demo_data.py b/database/demo_data.py index a4296412e..92d18557f 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -656,10 +656,10 @@ allocations = [ { "termCode": 202200, - "department": "Computer Science", - "isApproved": True, - "approvedOn": 2021-10-19, - "approvedBy": "Dr heggen", + "department": 3, + "isApproved": False, + "approvedOn": None, + "approvedBy": None, "justification": "Downscaling due to decrease in student enrollment caused by current economic conditions", "primary_10": 2, "primary_12": 2, @@ -670,13 +670,14 @@ "breakHours": 260, }, { - "termCode": 202300, - "department": "ETAD", - "isApproved": True, - "approvedOn": 2022-11-12, - "approvedBy": "Dr Jan", + "termCode": 202300, + "department": 2, + "isApproved": False, + "approvedOn": None, + "approvedBy": None, "justification": "Increase in student enrollment due to exodous from CS department", "primary_10": 4, + "primary_12": 2, "primary_15": 7, "primary_20": 4, "secondary_5": 2, @@ -685,10 +686,10 @@ }, { "termCode": 202400, - "department": "Mathematics", - "isApproved": True, - "approvedOn": 2023-12-19, - "approvedBy": "Dr Barnard", + "department": 1, + "isApproved": False, + "approvedOn": None, + "approvedBy": None, "justification": "We are hiring more students to help with the increased workload in the department", "primary_10": 5, "primary_12": 6, @@ -700,10 +701,10 @@ }, { "termCode": 202500, - "department": "Physics", - "isApproved": True, - "approvedOn": 2025-1-10, - "approvedBy": "Dr Hodge", + "department": 4, + "isApproved": False, + "approvedOn": None, + "approvedBy": None, "justification": "Downscaling the number of students in the department due to budget cuts", "primary_10": 4, "primary_12": 5, @@ -714,11 +715,11 @@ "breakHours": 300, }, { - "termCode": 202600, - "department": "Engineering Physics", - "isApproved": False, - "approvedOn": 2025-10-19, - "approvedBy": "Dr wu", + "termCode": 202500, + "department": 5, + "isApproved": False, + "approvedOn": None, + "approvedBy": None, "justification": "Due to rapid department growth, we need to hire more students to help with the increased workload", "primary_10": 8, "primary_12": 10, diff --git a/database/migrate_db.sh b/database/migrate_db.sh index f88c91f26..5788fbead 100755 --- a/database/migrate_db.sh +++ b/database/migrate_db.sh @@ -30,6 +30,7 @@ pem add app.models.supervisor.Supervisor pem add app.models.supervisorDepartment.SupervisorDepartment pem add app.models.studentLaborEvaluation.StudentLaborEvaluation pem add app.models.formSearchResult.FormSearchResult +pem add app.models.allocation.Allocation pem watch pem migrate From 30c5fe9d15d293e4a2b2bd912ff7d6b5e25c9d1b Mon Sep 17 00:00:00 2001 From: Dayton Conwell Date: Wed, 1 Jul 2026 15:04:58 +0000 Subject: [PATCH 19/72] fixed the format issue on demo data and made the composite key on positionhistory --- app/models/positionHistory.py | 4 ++-- database/demo_data.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/positionHistory.py b/app/models/positionHistory.py index 222441787..b8b834cc4 100644 --- a/app/models/positionHistory.py +++ b/app/models/positionHistory.py @@ -2,10 +2,10 @@ from app.models.department import Department class PositionHistory(baseModel): - positionID = PrimaryKeyField() positioncode = CharField() status = CharField() WLS = IntegerField() revisiondate = DateField() Description = TextField(default=None) - Department = ForeignKeyField(Department) + Department = ForeignKeyField(Department) +PositionHistory._meta.set_primary_key('positioncode_revisiondate_status', CompositeKey('positioncode', 'revisiondate', 'status')) diff --git a/database/demo_data.py b/database/demo_data.py index 7550d3e0d..65beebd14 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -662,6 +662,6 @@ "Description": "This is a test data for position history code 2", "Department_id" : 1 }, - } + ] PositionHistory.insert_many(positionhistory).on_conflict_replace().execute() \ No newline at end of file From 9b7e7786a71c90a1a3d89033d5bc7659492449ef Mon Sep 17 00:00:00 2001 From: Dayton Conwell Date: Wed, 1 Jul 2026 15:58:11 +0000 Subject: [PATCH 20/72] changed meta class in position history adn fixed identifiers in demo data --- app/models/positionHistory.py | 4 +++- database/demo_data.py | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/positionHistory.py b/app/models/positionHistory.py index b8b834cc4..399608a78 100644 --- a/app/models/positionHistory.py +++ b/app/models/positionHistory.py @@ -8,4 +8,6 @@ class PositionHistory(baseModel): revisiondate = DateField() Description = TextField(default=None) Department = ForeignKeyField(Department) -PositionHistory._meta.set_primary_key('positioncode_revisiondate_status', CompositeKey('positioncode', 'revisiondate', 'status')) + +class Meta: + primary_key = CompositeKey('positioncode', 'revisiondate', 'status') \ No newline at end of file diff --git a/database/demo_data.py b/database/demo_data.py index 65beebd14..1bc7e23f3 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -633,7 +633,7 @@ "positioncode": "S61408", "status": "Active", "WLS": 2, - "revisiondate": f"{current_year}-07-01", + "revisiondate": f"{current_year}-09-01", "Description": "", "Department_id": 1 }, @@ -650,8 +650,8 @@ "status": "Active", "WLS":3, "revisiondate" : f"{current_year}-01-01", - "Description": "This is a test data for position history code 1", - "Department_id" : 2 + "Description": "", + "Department_id" : 1 }, { @@ -659,7 +659,7 @@ "status": "Inactive", "WLS":2, "revisiondate" : f"{current_year}-01-01", - "Description": "This is a test data for position history code 2", + "Description": "", "Department_id" : 1 }, From a52eeca52cd0be83ba5faddc7629f77b3717bab5 Mon Sep 17 00:00:00 2001 From: Brian Ramsay Date: Thu, 2 Jul 2026 11:56:23 -0400 Subject: [PATCH 21/72] Add base for department portal --- app/controllers/main_routes/main_routes.py | 24 ++++++- app/static/css/base.css | 73 ++++++++++++++++++++++ app/static/js/departmentPortal.js | 6 ++ app/templates/main/departmentPortal.html | 27 ++++++++ app/templates/sidebar.html | 15 +++-- 5 files changed, 139 insertions(+), 6 deletions(-) create mode 100644 app/static/js/departmentPortal.js create mode 100644 app/templates/main/departmentPortal.html diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index b3af06c9e..0a2f21e4b 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -1,5 +1,5 @@ from flask import render_template, request, json, redirect, url_for, send_file, g, flash, jsonify -from peewee import JOIN +from peewee import JOIN, DoesNotExist from functools import reduce import operator from app.models.department import Department @@ -47,6 +47,26 @@ def supervisorPortal(): currentUser = currentUser ) +@main_bp.route('/department', methods=['GET']) +@main_bp.route('/department/', methods=['GET']) +@main_bp.route('/department//', methods=['GET']) +def departmentPortal(org=None,account=None): + try: + dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) + except (NameError, DoesNotExist): + dept = None + + + + if g.currentUser.isLaborAdmin: + departments = list(Department.select().order_by(Department.isActive.desc(), Department.DEPT_NAME.asc())) + else: + departments = list(getDepartmentsForSupervisor(g.currentUser).order_by(Department.isActive.desc(), Department.DEPT_NAME.asc())) + + return render_template('main/departmentPortal.html', + departments = departments, + department = dept) + @main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST']) def addUserToDept(): userDeptData = request.form @@ -113,4 +133,4 @@ def submitToBanner(formHistoryId): if save_form_status: return "Form successfully submitted to Banner.", 200 else: - return "Submitting to Banner failed.", 500 \ No newline at end of file + return "Submitting to Banner failed.", 500 diff --git a/app/static/css/base.css b/app/static/css/base.css index 916fb4db9..940f8d6e5 100755 --- a/app/static/css/base.css +++ b/app/static/css/base.css @@ -191,3 +191,76 @@ a { font-size:1.2em; z-index:999; } + +.card { + position: relative; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + min-width: 0; + word-wrap: break-word; + background-color: #fff; + background-clip: border-box; + border: 1px solid rgba(0, 0, 0, 0.125); + border-radius: 0.25rem; +} + +.card-body { + -webkit-box-flex: 1; + -ms-flex: 1 1 auto; + flex: 1 1 auto; + padding: 1rem 1rem; +} + +.card-title { + margin-bottom: 0.5rem; + font-size: 1.25rem; + font-weight: 500; +} + +.card-subtitle { + margin-top: -0.25rem; + margin-bottom: 0; +} + +.card-text:last-child { + margin-bottom: 0; +} + +.card-link + .card-link { + margin-left: 1rem; +} + +.card-header { + padding: 0.5rem 1rem; + margin-bottom: 0; + background-color: rgba(0, 0, 0, 0.03); + border-bottom: 1px solid rgba(0, 0, 0, 0.125); +} + +.card-header:first-child { + border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0; +} + +.card-footer { + padding: 0.5rem 1rem; + background-color: rgba(0, 0, 0, 0.03); + border-top: 1px solid rgba(0, 0, 0, 0.125); +} + +.card-footer:last-child { + border-radius: 0 0 calc(0.25rem - 1px) calc(0.25rem - 1px); +} + +.card-img, .card-img-top { + width: 100%; +} + +.card-img-top { + border-top-left-radius: calc(0.25rem - 1px); + border-top-right-radius: calc(0.25rem - 1px); +} diff --git a/app/static/js/departmentPortal.js b/app/static/js/departmentPortal.js new file mode 100644 index 000000000..cb2023a3a --- /dev/null +++ b/app/static/js/departmentPortal.js @@ -0,0 +1,6 @@ +$(document).ready(function() { + $("#selectedDepartment").on("change",function() { + deptData = $(this).find('option:selected').data(); + window.location = `/department/${deptData.org}/${deptData.account}`; + }); +}); diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html new file mode 100644 index 000000000..8ee01838b --- /dev/null +++ b/app/templates/main/departmentPortal.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} + +{% block scripts %} +{{super()}} + +{% endblock %} + +{% block app_content %} +

{% if department %} {{department.DEPT_NAME}} Portal {% else %} Choose a Department: {% endif %}

+ + +
+ + +
+{% endblock %} diff --git a/app/templates/sidebar.html b/app/templates/sidebar.html index 323b6b03b..1486f7de2 100644 --- a/app/templates/sidebar.html +++ b/app/templates/sidebar.html @@ -49,17 +49,24 @@

Labor History

{% if currentUser.supervisor %}
+ {% endif %} {% if currentUser.supervisor or (currentUser.student and currentUser.isLaborAdmin) %}
- -
+ +

New Labor Status Form

@@ -67,7 +74,7 @@

New Labor Status Form

{% endif %} {% if currentUser.supervisor or (currentUser.student and currentUser.isLaborAdmin) %}
-
+

Department Portal

From ba5a40b6175ba98a71bf487ab54b06dd349d620f Mon Sep 17 00:00:00 2001 From: Brian Ramsay Date: Thu, 2 Jul 2026 16:01:35 -0400 Subject: [PATCH 23/72] Add empty file for common routes --- app/controllers/main_routes/departmentPortal.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 app/controllers/main_routes/departmentPortal.py diff --git a/app/controllers/main_routes/departmentPortal.py b/app/controllers/main_routes/departmentPortal.py new file mode 100644 index 000000000..351757701 --- /dev/null +++ b/app/controllers/main_routes/departmentPortal.py @@ -0,0 +1 @@ +from flask import render_template From 7c1adec948ec65c3f8251214bdff90de9877b59b Mon Sep 17 00:00:00 2001 From: BhushanSah Date: Thu, 2 Jul 2026 21:04:00 +0000 Subject: [PATCH 24/72] Added member card --- app/static/css/base.css | 32 ++++++++++ app/templates/main/departmentPortal.html | 80 ++++++++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/app/static/css/base.css b/app/static/css/base.css index 940f8d6e5..9c5d8e2fb 100755 --- a/app/static/css/base.css +++ b/app/static/css/base.css @@ -264,3 +264,35 @@ a { border-top-left-radius: calc(0.25rem - 1px); border-top-right-radius: calc(0.25rem - 1px); } + + +.members-card .media { + margin-bottom: 18px; +} + +.members-card h4 { + margin-top: 18px; + margin-bottom: 4px; +} + +.members-card-icon { + display: inline-block; + width: 42px; + height: 42px; + line-height: 42px; + text-align: center; + border-radius: 50%; + background-color: #e8edf3; + color: #7c8ea1; + font-size: 18px; +} + +.members-card-cta { + position: relative; + display: inline-block; +} + +.members-card-btn { + border-radius: 20px; + padding: 8px 20px; +} diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 8ee01838b..6238bfe07 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -3,6 +3,8 @@ {% block scripts %} {{super()}} + {% endblock %} {% block app_content %} @@ -24,4 +26,82 @@

{% if department %} {{department.DEPT_NAME}} Portal {% e

+ + +
+
+
+ +
+
+ +
+ +
+

+ Members +

+
+
+ +

Labor Coordinator

+

Dr. Jones

+ +

Supervisors

+

+ Dr. Heggen
+ Dr. Nakazawa +

+ +

+ + + View Details + + + +

+ +
+
+
{% endblock %} + + From cc07c972721e3107e01a9a81896e97f0ac71675b Mon Sep 17 00:00:00 2001 From: nahom70 Date: Thu, 2 Jul 2026 21:05:35 +0000 Subject: [PATCH 25/72] tried to add it --- app/templates/main/managepositions.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/templates/main/managepositions.html diff --git a/app/templates/main/managepositions.html b/app/templates/main/managepositions.html new file mode 100644 index 000000000..b78750533 --- /dev/null +++ b/app/templates/main/managepositions.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + +{% block styles %} +{{super()}} + +{% endblock %} + +{% block scripts %} +{{super()}} + +{% endblock %} + +{% block app_content %} +

{{ department_name }}

+

Manage Positions

+ + +{% endblock %} \ No newline at end of file From 6bb3e689b95c263fd766bdf43b2a4c74228afb32 Mon Sep 17 00:00:00 2001 From: Dayton Conwell Date: Thu, 2 Jul 2026 21:06:38 +0000 Subject: [PATCH 26/72] some change --- app/templates/main/departmentPortal.html | 14 ++++++++++++++ app/templates/main/supervisorPortal.html | 2 +- database/reset_database.sh | 14 +++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 8ee01838b..18a6b9f64 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -8,6 +8,20 @@ {% block app_content %}

{% if department %} {{department.DEPT_NAME}} Portal {% else %} Choose a Department: {% endif %}

+
+
+
+ + + + + Current Allocation +
+


AY 26/27 15/20 POSITIONS

Break Hours 0 of 200 hrs

+ Go somewhere +
+
+
diff --git a/database/reset_database.sh b/database/reset_database.sh index 82f6cff53..ad6dbd91f 100755 --- a/database/reset_database.sh +++ b/database/reset_database.sh @@ -8,7 +8,7 @@ if [ "$1" != "test" ] && [ "$1" != "from-backup" ]; then fi cd database; - + PRODUCTION=0 if [ "`hostname`" == 'lsf.berea.edu' ]; then echo "DO NOT RUN THIS SCRIPT ON PRODUCTION UNLESS YOU REALLY REALLY KNOW WHAT YOU ARE DOING" @@ -22,12 +22,12 @@ if [ "$1" == "from-backup" ]; then fi echo "Dropping databases" -mysql -u root -proot --execute="DROP DATABASE \`lsf\`; DROP USER 'lsf_user';" -mysql -u root -proot --execute="DROP DATABASE \`UTE\`; DROP USER 'tracy_user';" +mysql -u root -proot --skip-ssl --execute="DROP DATABASE \`lsf\`; DROP USER 'lsf_user';" +mysql -u root -proot --skip-ssl --execute="DROP DATABASE \`UTE\`; DROP USER 'tracy_user';" echo "Recreating databases and users" -mysql -u root -proot --execute="CREATE DATABASE IF NOT EXISTS \`lsf\`; CREATE USER IF NOT EXISTS 'lsf_user'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'lsf_user'@'%';" -mysql -u root -proot --execute="CREATE DATABASE IF NOT EXISTS \`UTE\`; CREATE USER IF NOT EXISTS 'tracy_user'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'tracy_user'@'%';" +mysql -u root -proot --skip-ssl --execute="CREATE DATABASE IF NOT EXISTS \`lsf\`; CREATE USER IF NOT EXISTS 'lsf_user'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'lsf_user'@'%';" +mysql -u root -proot --skip-ssl --execute="CREATE DATABASE IF NOT EXISTS \`UTE\`; CREATE USER IF NOT EXISTS 'tracy_user'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'tracy_user'@'%';" cd database @@ -38,14 +38,14 @@ rm -rf migrations.json echo "Creating database objects" if [ $BACKUP -eq 1 ]; then echo " from backup" - mysql -u root -proot lsf < prod-backup.sql + mysql -u root -proot --skip-ssl lsf < prod-backup.sql else echo " empty" ./migrate_db.sh fi if [ $PRODUCTION -ne 1 ]; then - ./migrate_db_tracy.sh + ./migrate_db_tracy.sh fi rm -rf lsf_migrations From c29f01f461b8eb2a149605830f3506ea2caebde7 Mon Sep 17 00:00:00 2001 From: lolongaj Date: Thu, 2 Jul 2026 21:10:05 +0000 Subject: [PATCH 27/72] added 3 sample buttons to learn HTML --- app/templates/main/departmentPortal.html | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 8ee01838b..73f0c783c 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -4,7 +4,6 @@ {{super()}} {% endblock %} - {% block app_content %}

{% if department %} {{department.DEPT_NAME}} Portal {% else %} Choose a Department: {% endif %}

@@ -24,4 +23,23 @@

{% if department %} {{department.DEPT_NAME}} Portal {% e

-{% endblock %} +
+
+
+

Positions

+

Student Programmer

+ View Details +
+
+
+

burrh

+
+
+
+

Positions

+

Student Programmer

+ View Details +
+
+
+{% endblock %}\ \ No newline at end of file From aa3a837d23f7543684ae0275dd86681ee63a0d0b Mon Sep 17 00:00:00 2001 From: fritzj2 Date: Fri, 3 Jul 2026 13:17:42 +0000 Subject: [PATCH 28/72] uniform sizing for cards that scale with the screen and no cards when no department is selected --- app/templates/main/departmentPortal.html | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 73f0c783c..e31f476bf 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -23,15 +23,17 @@

{% if department %} {{department.DEPT_NAME}} Portal {% e

-
-
+ +{% if department %} +
+

Positions

-

Student Programmer

+

{{department.ACCOUNT}}

View Details
-
+

burrh

@@ -42,4 +44,9 @@

Positions

+
+

aaaaaa

+
+{% endif %} + {% endblock %}\ \ No newline at end of file From 645e85ae93f8b743030a98a3160389194530c790 Mon Sep 17 00:00:00 2001 From: fritzj2 Date: Fri, 3 Jul 2026 15:38:25 +0000 Subject: [PATCH 29/72] added a 10 position cap to the amount of visible positons --- app/controllers/main_routes/main_routes.py | 11 +++++++++-- app/templates/main/departmentPortal.html | 22 ++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 0a2f21e4b..18c0f3963 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -16,6 +16,7 @@ from app.login_manager import require_login, logout from app.logic.getTableData import getDatatableData from app.logic.banner import Banner +from app.logic.tracy import Tracy @main_bp.route('/logout', methods=['GET']) def triggerLogout(): @@ -62,10 +63,16 @@ def departmentPortal(org=None,account=None): departments = list(Department.select().order_by(Department.isActive.desc(), Department.DEPT_NAME.asc())) else: departments = list(getDepartmentsForSupervisor(g.currentUser).order_by(Department.isActive.desc(), Department.DEPT_NAME.asc())) - + + pos = Tracy().getPositionsFromDepartment(org, account) + positions = [] + for i in pos: + positions.append(i.POSN_TITLE + "" + "(" + i.WLS + ")") + print(positions) return render_template('main/departmentPortal.html', departments = departments, - department = dept) + department = dept, + positions = positions) @main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST']) def addUserToDept(): diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index e31f476bf..1f3e9e422 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -23,30 +23,36 @@

{% if department %} {{department.DEPT_NAME}} Portal {% e

- + {% if department %}
-

Positions

+

that one thing

{{department.ACCOUNT}}

View Details
-
-

burrh

+
+
+

burrh

+

crazy interesting stuff here

+ View Details +

Positions

-

Student Programmer

+ {% for p in positions %} + {% if 10 > loop.index0 %} +

{{ p }}

+ {% endif %} + {% endfor %} View Details
-
-

aaaaaa

-
+ {% endif %} {% endblock %}\ \ No newline at end of file From d3c0b0401958ff6a147be8142468e92c68938acc Mon Sep 17 00:00:00 2001 From: fritzj2 Date: Fri, 3 Jul 2026 15:40:44 +0000 Subject: [PATCH 30/72] removed an unecessary print statement from the main_routes.py --- app/controllers/main_routes/main_routes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 18c0f3963..36bd7cb05 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -68,7 +68,7 @@ def departmentPortal(org=None,account=None): positions = [] for i in pos: positions.append(i.POSN_TITLE + "" + "(" + i.WLS + ")") - print(positions) + return render_template('main/departmentPortal.html', departments = departments, department = dept, From dfa597131f5dc3ca3529c442cf3c6ab83696ce35 Mon Sep 17 00:00:00 2001 From: nyabutoa Date: Fri, 3 Jul 2026 19:11:32 +0000 Subject: [PATCH 31/72] we added some things and the table we hard coded some information in there but we will be connecting it soon to tracy and get actaul information --- app/controllers/main_routes/main_routes.py | 25 ++++- app/templates/main/departmentPortal.html | 2 +- app/templates/main/managepositions.html | 117 +++++++++++++++++++-- 3 files changed, 132 insertions(+), 12 deletions(-) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 36bd7cb05..527244cb6 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -52,9 +52,12 @@ def supervisorPortal(): @main_bp.route('/department/', methods=['GET']) @main_bp.route('/department//', methods=['GET']) def departmentPortal(org=None,account=None): - try: - dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) - except (NameError, DoesNotExist): + if org and account: + try: + dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) + except (NameError, DoesNotExist): + dept = None + else: dept = None @@ -69,11 +72,25 @@ def departmentPortal(org=None,account=None): for i in pos: positions.append(i.POSN_TITLE + "" + "(" + i.WLS + ")") - return render_template('main/departmentPortal.html', + return render_template('main/departmentPortal.html', departments = departments, department = dept, positions = positions) +@main_bp.route('/department///managepositions', methods=['GET']) +def managePositions(org, account): + try: + dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) + except DoesNotExist: + return render_template('errors/404.html'), 404 + + positions = Tracy().getPositionsFromDepartment(org, account) + + return render_template('main/managepositions.html', + department = dept, + department_name = dept.DEPT_NAME, + positions = positions) + @main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST']) def addUserToDept(): userDeptData = request.form diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 1f3e9e422..a00a298b2 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -48,7 +48,7 @@

Positions

{{ p }}

{% endif %} {% endfor %} - View Details + View Details
diff --git a/app/templates/main/managepositions.html b/app/templates/main/managepositions.html index b78750533..9c38e7f52 100644 --- a/app/templates/main/managepositions.html +++ b/app/templates/main/managepositions.html @@ -2,17 +2,120 @@ {% block styles %} {{super()}} - + {% endblock %} {% block scripts %} {{super()}} - + {% endblock %} {% block app_content %} -

{{ department_name }}

-

Manage Positions

- - -{% endblock %} \ No newline at end of file +
+

{{ department_name }}

+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Position (WSL)Position CodeStatusLast Revision DateView Position DescriptionEdit Position Description
TA (3)S85405 + + Active + + 01/01/2024 + + + +
Co-Lead TA (4)S89123 + + Requested + + 01/01/2024 + + + +
Lead TA (4)S89123 + + Inactive + + 01/01/2024 + + + +
+
+

+ Total Positions: + 3 +

+
+{% endblock %} From 693191bfd9161858047801e2b8555bd58f8dc1ae Mon Sep 17 00:00:00 2001 From: fritzj2 Date: Fri, 3 Jul 2026 20:31:48 +0000 Subject: [PATCH 32/72] got the first card added from Dayton's branch --- app/templates/main/departmentPortal.html | 32 ++++++++++-------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 86a15e6ce..fa226dca7 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -7,19 +7,6 @@ {% block app_content %}

{% if department %} {{department.DEPT_NAME}} Portal {% else %} Choose a Department: {% endif %}

-
-
-
- - - - - Current Allocation -
-


AY 26/27 15/20 POSITIONS

Break Hours 0 of 200 hrs

- Go somewhere -
-
@@ -40,13 +27,20 @@
{% if department %}
-
-
-

that one thing

-

{{department.ACCOUNT}}

- View Details -
+ +
+
+
+ + + + + Current Allocation +
+


AY 26/27 15/20 POSITIONS

Break Hours 0 of 200 hrs

+ Go somewhere
+

burrh

From 1bb8c18f69e2779e29ba9a654b49c61d50073547 Mon Sep 17 00:00:00 2001 From: fritzj2 Date: Fri, 3 Jul 2026 21:23:04 +0000 Subject: [PATCH 33/72] added real people into the members card, its wrong and gives us everyone --- app/controllers/main_routes/main_routes.py | 10 +++++++++- app/templates/main/departmentPortal.html | 17 +++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 36bd7cb05..17fa6f2a2 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -69,10 +69,18 @@ def departmentPortal(org=None,account=None): for i in pos: positions.append(i.POSN_TITLE + "" + "(" + i.WLS + ")") + staff = Tracy().getSupervisors() + supervisors = [] + + for i in staff: + if i.DEPT_NAME == Department.DEPT_NAME: + supervisors.append(i.FIRST_NAME + " " + i.LAST_NAME + " (" + i.EMAIL + ")") + return render_template('main/departmentPortal.html', departments = departments, department = dept, - positions = positions) + positions = positions, + supervisors = supervisors) @main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST']) def addUserToDept(): diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index a221f7160..bc3710bd7 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -45,7 +45,6 @@
-
@@ -53,22 +52,23 @@
-

Members

- -

Labor Coordinator

+

Labor Coordinator(s)

Dr. Jones

Supervisors

-

- Dr. Heggen
- Dr. Nakazawa -

+ {% for s in supervisors %} + {% if 3 > loop.index0 %} +

{{ s }}

+ {% elif 4 > loop.index0 %} +

and {{ supervisors | length}} more...

+ {% endif %} + {% endfor %}
+

Positions

From 3f6aa594d26c04ff25ded1fb935925cfa7b99e46 Mon Sep 17 00:00:00 2001 From: fritzj2 Date: Mon, 6 Jul 2026 13:17:24 +0000 Subject: [PATCH 34/72] changed the button from members to blue --- app/templates/main/departmentPortal.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index bc3710bd7..fd29a2ec3 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -53,15 +53,15 @@
-

+

Members -

+

Labor Coordinator(s)

Dr. Jones

-

Supervisors

+

Supervisors

{% for s in supervisors %} {% if 3 > loop.index0 %}

{{ s }}

@@ -72,8 +72,8 @@

Supervisors

From 77e9714189a8ed1a1c0105470fcbc7944edd4af8 Mon Sep 17 00:00:00 2001 From: fritzj2 Date: Mon, 6 Jul 2026 13:25:46 +0000 Subject: [PATCH 35/72] added the bottom border and centered the button --- app/templates/main/departmentPortal.html | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index fd29a2ec3..33f82f747 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -78,17 +78,19 @@

Supervisors

-
-
-

Positions

- {% for p in positions %} - {% if 10 > loop.index0 %} -

{{ p }}

- {% endif %} - {% endfor %} - View Details -
+
+
+

Positions

+ {% for p in positions %} + {% if 10 > loop.index0 %} +

{{ p }}

+ {% endif %} + {% endfor %}
+ +
{% endif %} From abcd951f493146b284bae8c55717d8c598dc0862 Mon Sep 17 00:00:00 2001 From: rukwashai Date: Mon, 6 Jul 2026 09:57:32 -0400 Subject: [PATCH 36/72] Add real data to the Current Allocation card - New Allocation model (department, term, totalPositions, totalBreakHours) - Register Allocation in migrate_db.sh - Seed demo allocation rows per department in demo_data.py - departmentPortal route now queries Allocation for the selected dept and open term, and computes positions/break-hours used from LaborStatusForm - Template renders real allocation data instead of hardcoded placeholder text --- app/controllers/main_routes/main_routes.py | 23 +++++++++++++++++++--- app/models/allocation.py | 9 +++++++++ app/templates/main/departmentPortal.html | 9 +++++++-- database/demo_data.py | 15 ++++++++++++++ database/migrate_db.sh | 1 + 5 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 app/models/allocation.py diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 17fa6f2a2..3dd3fa40b 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -1,8 +1,9 @@ from flask import render_template, request, json, redirect, url_for, send_file, g, flash, jsonify -from peewee import JOIN, DoesNotExist +from peewee import JOIN, DoesNotExist, fn from functools import reduce import operator from app.models.department import Department +from app.models.allocation import Allocation from app.models.supervisor import Supervisor from app.models.supervisorDepartment import SupervisorDepartment from app.models.student import Student @@ -76,11 +77,27 @@ def departmentPortal(org=None,account=None): if i.DEPT_NAME == Department.DEPT_NAME: supervisors.append(i.FIRST_NAME + " " + i.LAST_NAME + " (" + i.EMAIL + ")") - return render_template('main/departmentPortal.html', + allocation = None + positionsUsed = 0 + breakHoursUsed = 0 + if dept and g.openTerm: + allocation = Allocation.get_or_none(Allocation.department == dept, Allocation.term == g.openTerm) + usage = (LaborStatusForm + .select(fn.COUNT(LaborStatusForm.laborStatusFormID).alias('positionCount'), + fn.SUM(LaborStatusForm.contractHours).alias('hoursSum')) + .where(LaborStatusForm.department == dept, LaborStatusForm.termCode == g.openTerm) + .get()) + positionsUsed = usage.positionCount or 0 + breakHoursUsed = usage.hoursSum or 0 + + return render_template('main/departmentPortal.html', departments = departments, department = dept, positions = positions, - supervisors = supervisors) + supervisors = supervisors, + allocation = allocation, + positionsUsed = positionsUsed, + breakHoursUsed = breakHoursUsed) @main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST']) def addUserToDept(): diff --git a/app/models/allocation.py b/app/models/allocation.py new file mode 100644 index 000000000..f67b61e3e --- /dev/null +++ b/app/models/allocation.py @@ -0,0 +1,9 @@ +from app.models import * +from app.models.department import Department +from app.models.term import Term + +class Allocation(baseModel): + department = ForeignKeyField(Department, on_delete="cascade") + term = ForeignKeyField(Term, on_delete="cascade") + totalPositions = IntegerField() + totalBreakHours = IntegerField() diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index fd29a2ec3..d77f22f8e 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -39,8 +39,13 @@
Current Allocation
-


AY 26/27 15/20 POSITIONS

Break Hours 0 of 200 hrs

- Go somewhere + {% if allocation %} +


{{allocation.term.termName}} {{positionsUsed}}/{{allocation.totalPositions}} POSITIONS +

Break Hours {{breakHoursUsed}} of {{allocation.totalBreakHours}} hrs

+ {% else %} +


No allocation set for this term.

+ {% endif %} + View Details diff --git a/database/demo_data.py b/database/demo_data.py index 0557c9361..1bb4c3b6a 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -530,6 +530,21 @@ Term.insert_many(terms).on_conflict_replace().execute() print(f" * terms for {current_year}-{current_year+1} added") +############################# +# Allocation +############################# +from app.models.allocation import Allocation + +allocations = [ + {"department": 1, "term": f"{current_year}00", "totalPositions": 20, "totalBreakHours": 200}, + {"department": 2, "term": f"{current_year}00", "totalPositions": 12, "totalBreakHours": 150}, + {"department": 3, "term": f"{current_year}00", "totalPositions": 15, "totalBreakHours": 180}, + {"department": 4, "term": f"{current_year}00", "totalPositions": 10, "totalBreakHours": 100}, + {"department": 5, "term": f"{current_year}00", "totalPositions": 20, "totalBreakHours": 200}, +] +Allocation.insert_many(allocations).on_conflict_replace().execute() +print(" * allocations added") + ############################# # Create a Pending Labor Status Form ############################# diff --git a/database/migrate_db.sh b/database/migrate_db.sh index f88c91f26..472aab283 100755 --- a/database/migrate_db.sh +++ b/database/migrate_db.sh @@ -16,6 +16,7 @@ pem add app.models.laborStatusForm.LaborStatusForm pem add app.models.laborReleaseForm.LaborReleaseForm pem add app.models.term.Term pem add app.models.department.Department +pem add app.models.allocation.Allocation pem add app.models.emailTemplate.EmailTemplate pem add app.models.formHistory.FormHistory pem add app.models.adjustedForm.AdjustedForm From 6c52ca9eb6d46a7acd83413a7716254c9b8b7df0 Mon Sep 17 00:00:00 2001 From: BhushanSah Date: Mon, 6 Jul 2026 14:08:08 +0000 Subject: [PATCH 37/72] fixedgit add app/controllers/main_routes/main_routes.py Now current dept show the supervisor of current department only --- app/controllers/main_routes/main_routes.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 17fa6f2a2..a10c46cc8 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -56,9 +56,7 @@ def departmentPortal(org=None,account=None): dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) except (NameError, DoesNotExist): dept = None - - - + if g.currentUser.isLaborAdmin: departments = list(Department.select().order_by(Department.isActive.desc(), Department.DEPT_NAME.asc())) else: @@ -73,7 +71,8 @@ def departmentPortal(org=None,account=None): supervisors = [] for i in staff: - if i.DEPT_NAME == Department.DEPT_NAME: + print(f"org= {org},----- account= {account}") + if i.ORG == org: supervisors.append(i.FIRST_NAME + " " + i.LAST_NAME + " (" + i.EMAIL + ")") return render_template('main/departmentPortal.html', From cdabc2a68f6047bbc892c313cc7d4bcd004c9054 Mon Sep 17 00:00:00 2001 From: Dayton Conwell Date: Mon, 6 Jul 2026 14:14:20 +0000 Subject: [PATCH 38/72] added changes to format with all 3 cards --- app/templates/main/departmentPortal.html | 37 +++++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index bc3710bd7..78fda0498 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -30,19 +30,34 @@

{% if department %} {{department.DEPT_NAME}} Portal {% e {% if department %}
-
+
-
- - - - - Current Allocation -
-


AY 26/27 15/20 POSITIONS

Break Hours 0 of 200 hrs

- Go somewhere +
+
+ + + +
+
+

+ Current Allocation +

+
+
+

AY 26/27      15 / 20 Positions

+

Break Hours      0 of 200 Hrs.

-
+ + + +
From ea79ff6ebb275ccbf8c1f02350653583a80a428a Mon Sep 17 00:00:00 2001 From: fritzj2 Date: Mon, 6 Jul 2026 14:28:55 +0000 Subject: [PATCH 39/72] unordered list now bullets elements, icon is in the top right, and round corners --- app/templates/main/departmentPortal.html | 29 ++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 33f82f747..0487d8138 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -28,9 +28,9 @@

{% if department %} {{department.DEPT_NAME}} Portal {% e

{% if department %} -
+
-
+
@@ -44,7 +44,7 @@
-
+
@@ -78,14 +78,29 @@

Supervisors

-
+
-

Positions

+
+
+

Positions

+
+
+ +
+ +
+
    {% for p in positions %} - {% if 10 > loop.index0 %} -

    {{ p }}

    + {% if 7 > loop.index0 %} +
  • {{ p }}
  • + {% elif 8 == loop.index0 %} +

and {{ positions | length}} more...

{% endif %} {% endfor %} + +
diff --git a/database/demo_data.py b/database/demo_data.py index 1bb4c3b6a..0557c9361 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -530,21 +530,6 @@ Term.insert_many(terms).on_conflict_replace().execute() print(f" * terms for {current_year}-{current_year+1} added") -############################# -# Allocation -############################# -from app.models.allocation import Allocation - -allocations = [ - {"department": 1, "term": f"{current_year}00", "totalPositions": 20, "totalBreakHours": 200}, - {"department": 2, "term": f"{current_year}00", "totalPositions": 12, "totalBreakHours": 150}, - {"department": 3, "term": f"{current_year}00", "totalPositions": 15, "totalBreakHours": 180}, - {"department": 4, "term": f"{current_year}00", "totalPositions": 10, "totalBreakHours": 100}, - {"department": 5, "term": f"{current_year}00", "totalPositions": 20, "totalBreakHours": 200}, -] -Allocation.insert_many(allocations).on_conflict_replace().execute() -print(" * allocations added") - ############################# # Create a Pending Labor Status Form ############################# diff --git a/database/migrate_db.sh b/database/migrate_db.sh index 472aab283..f88c91f26 100755 --- a/database/migrate_db.sh +++ b/database/migrate_db.sh @@ -16,7 +16,6 @@ pem add app.models.laborStatusForm.LaborStatusForm pem add app.models.laborReleaseForm.LaborReleaseForm pem add app.models.term.Term pem add app.models.department.Department -pem add app.models.allocation.Allocation pem add app.models.emailTemplate.EmailTemplate pem add app.models.formHistory.FormHistory pem add app.models.adjustedForm.AdjustedForm From c1ffd5738b7dbf7b0ef2a829b91bc942acced7c9 Mon Sep 17 00:00:00 2001 From: BhushanSah Date: Mon, 6 Jul 2026 14:59:05 +0000 Subject: [PATCH 41/72] fixed supervisor for members card --- app/controllers/main_routes/main_routes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index a10c46cc8..62ad00b7f 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -71,7 +71,6 @@ def departmentPortal(org=None,account=None): supervisors = [] for i in staff: - print(f"org= {org},----- account= {account}") if i.ORG == org: supervisors.append(i.FIRST_NAME + " " + i.LAST_NAME + " (" + i.EMAIL + ")") From 725ce6aa4a89db39417930ca714bdadf88eb8aa2 Mon Sep 17 00:00:00 2001 From: nahom70 Date: Mon, 6 Jul 2026 15:15:30 +0000 Subject: [PATCH 42/72] polished the UI --- app/static/css/managepositions.css | 15 +++++++ app/templates/main/managepositions.html | 52 ++++++++++++------------- 2 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 app/static/css/managepositions.css diff --git a/app/static/css/managepositions.css b/app/static/css/managepositions.css new file mode 100644 index 000000000..9c40bbe38 --- /dev/null +++ b/app/static/css/managepositions.css @@ -0,0 +1,15 @@ +.width-12{ + width:12%; +} + +*{ + /* outline:solid 1px lime; */ + margin:0; + padding:0; + box-sizing:border-box; +} + +.department-header{ + padding:1%; + margin-top:-20px; +} \ No newline at end of file diff --git a/app/templates/main/managepositions.html b/app/templates/main/managepositions.html index 9c38e7f52..8cea7d3ef 100644 --- a/app/templates/main/managepositions.html +++ b/app/templates/main/managepositions.html @@ -2,7 +2,7 @@ {% block styles %} {{super()}} - + {% endblock %} {% block scripts %} @@ -11,39 +11,37 @@ {% endblock %} {% block app_content %} -
-

{{ department_name }}

+
+

{{ department_name }}

+ {% endblock %} diff --git a/database/demo_data.py b/database/demo_data.py index ade1c6379..ee91a4385 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -17,15 +17,11 @@ from app.models.laborStatusForm import LaborStatusForm from app.models.formHistory import FormHistory from app.models.notes import Notes -<<<<<<< HEAD -from app.models.supervisorDepartment import SupervisorDepartment -======= from app.models.allocation import Allocation from app.models.positionHistory import PositionHistory from app.models.supervisorDepartment import SupervisorDepartment from app.models.allocation import Allocation ->>>>>>> PeeWeeAttribute print("Inserting data for demo and testing purposes") From 62d5a13d124d8f5dbc7d87107296754bfb4ffe80 Mon Sep 17 00:00:00 2001 From: Dayton Conwell Date: Tue, 7 Jul 2026 15:19:03 +0000 Subject: [PATCH 50/72] added changes from demo --- app/templates/main/departmentPortal.html | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 3c01318df..06d1e837c 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -35,7 +35,7 @@

{% if department %} {{department.DEPT_NAME}} Portal {% e

@@ -43,22 +43,28 @@

Current Allocation

AY 26/27

15/20 Positions

+
    -
  • 10 HR : 2
  • -
  • 12 HR : 3
  • -
  • 15 HR : 5
  • -
  • 20 HR : 5
  • +
  • 10 Hour - 2/2
  • +
  • 12 Hour - 3/3
  • +
  • 15 Hour - 5/5
  • +
  • 20 Hour - 5/5
+
    +
  • 5 Hour - 2/2
  • +
  • 10 Hour - 3/3
  • +
+
-

Break Hours

0 of 200 Hrs.

+

Break Hours

0/200 Hours

From ffe248f412aa2ca006a631fcee86add02103e647 Mon Sep 17 00:00:00 2001 From: rukwashai Date: Tue, 7 Jul 2026 12:05:20 -0400 Subject: [PATCH 51/72] Fix duplicate style attribute and stray backslash in departmentPortal.html --- app/templates/main/departmentPortal.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 06d1e837c..b40f7a4aa 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -27,7 +27,7 @@

{% if department %} {{department.DEPT_NAME}} Portal {% e

{% if department %} -
+
@@ -138,7 +138,7 @@

Positions

{% endif %} -{% endblock %}\ +{% endblock %} From b4d408ffa6b34a0d50df12fc4648bf4069ad0efd Mon Sep 17 00:00:00 2001 From: rukwashai Date: Tue, 7 Jul 2026 14:24:52 -0400 Subject: [PATCH 52/72] Wire Current Allocation card to real Allocation/LaborStatusForm data (#602) Fix migrate_db.sh missing the Allocation model, seed demo Allocation rows per department, and query real allocated/used position counts and break hours in departmentPortal() instead of hardcoded placeholder numbers. --- app/controllers/main_routes/main_routes.py | 61 +++++++++++++++- app/templates/main/departmentPortal.html | 20 +++--- database/demo_data.py | 84 ++++++++++++++++++++++ database/migrate_db.sh | 1 + 4 files changed, 155 insertions(+), 11 deletions(-) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 7fc414b75..71e44bfdf 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -1,5 +1,5 @@ from flask import render_template, request, json, redirect, url_for, send_file, g, flash, jsonify -from peewee import JOIN, DoesNotExist +from peewee import JOIN, DoesNotExist, fn from functools import reduce import operator from app.models.department import Department @@ -9,6 +9,7 @@ from app.models.laborStatusForm import LaborStatusForm from app.models.formHistory import FormHistory from app.models.term import Term +from app.models.allocation import Allocation from app.controllers.admin_routes.allPendingForms import checkAdjustment from app.controllers.main_routes import main_bp from app.logic.download import CSVMaker, saveFormSearchResult, retrieveFormSearchResult @@ -80,11 +81,65 @@ def departmentPortal(org=None,account=None): if i.ORG == org: supervisors.append(i.FIRST_NAME + " " + i.LAST_NAME + " (" + i.EMAIL + ")") - return render_template('main/departmentPortal.html', + allocation = None + allocationBands = None + totalPositionsAllocated = None + totalPositionsUsed = None + breakHoursUsed = None + if dept and g.openTerm: + allocation = Allocation.get_or_none(Allocation.department == dept, Allocation.termCode == g.openTerm) + if allocation: + bandFields = [ + ('primary_10', 'Primary', 10), + ('primary_12', 'Primary', 12), + ('primary_15', 'Primary', 15), + ('primary_20', 'Primary', 20), + ('secondary_5', 'Secondary', 5), + ('secondary_10', 'Secondary', 10), + ] + allocationBands = {} + for fieldName, jobType, hours in bandFields: + used = (LaborStatusForm + .select() + .join(FormHistory, on=(FormHistory.formID == LaborStatusForm.laborStatusFormID)) + .where(LaborStatusForm.department == dept, + LaborStatusForm.termCode == g.openTerm, + LaborStatusForm.jobType == jobType, + LaborStatusForm.weeklyHours == hours, + FormHistory.historyType == "Labor Status Form", + ~(FormHistory.status % "Denied%")) + .distinct() + .count()) + allocationBands[fieldName] = {'used': used, 'allocated': getattr(allocation, fieldName)} + + totalPositionsAllocated = sum(band['allocated'] for band in allocationBands.values()) + totalPositionsUsed = sum(band['used'] for band in allocationBands.values()) + + # Break hours are tracked on separate break-term rows (e.g. Thanksgiving Break) + # that share the same academic year prefix as the open AY term. + yearPrefix = str(g.openTerm.termCode)[:-2] + breakTermCodes = [t.termCode for t in Term.select().where(Term.isBreak == True) + if str(t.termCode).startswith(yearPrefix)] + breakHoursUsed = (LaborStatusForm + .select(fn.SUM(LaborStatusForm.contractHours)) + .join(FormHistory, on=(FormHistory.formID == LaborStatusForm.laborStatusFormID)) + .where(LaborStatusForm.department == dept, + LaborStatusForm.termCode.in_(breakTermCodes), + FormHistory.historyType == "Labor Status Form", + ~(FormHistory.status % "Denied%")) + .scalar()) or 0 + + return render_template('main/departmentPortal.html', departments = departments, department = dept, positions = positions, - supervisors = supervisors) + supervisors = supervisors, + allocation = allocation, + allocationBands = allocationBands, + totalPositionsAllocated = totalPositionsAllocated, + totalPositionsUsed = totalPositionsUsed, + breakHoursUsed = breakHoursUsed, + currentTerm = g.openTerm) @main_bp.route('/department///managepositions', methods=['GET']) def managePositions(org, account): diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index b40f7a4aa..15eddc229 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -41,23 +41,27 @@

Allocations

-

AY 26/27

15/20 Positions

+

{{ currentTerm.termName if currentTerm else "No open term" }}

+

{{ totalPositionsUsed if allocation else "No allocation" }}{% if allocation %}/{{ totalPositionsAllocated }}{% endif %} Positions

+ {% if allocation %}
    -
  • 10 Hour - 2/2
  • -
  • 12 Hour - 3/3
  • -
  • 15 Hour - 5/5
  • -
  • 20 Hour - 5/5
  • +
  • 10 Hour - {{ allocationBands.primary_10.used }}/{{ allocationBands.primary_10.allocated }}
  • +
  • 12 Hour - {{ allocationBands.primary_12.used }}/{{ allocationBands.primary_12.allocated }}
  • +
  • 15 Hour - {{ allocationBands.primary_15.used }}/{{ allocationBands.primary_15.allocated }}
  • +
  • 20 Hour - {{ allocationBands.primary_20.used }}/{{ allocationBands.primary_20.allocated }}
    -
  • 5 Hour - 2/2
  • -
  • 10 Hour - 3/3
  • +
  • 5 Hour - {{ allocationBands.secondary_5.used }}/{{ allocationBands.secondary_5.allocated }}
  • +
  • 10 Hour - {{ allocationBands.secondary_10.used }}/{{ allocationBands.secondary_10.allocated }}
+ {% endif %}
-

Break Hours

0/200 Hours

+

Break Hours

+

{{ breakHoursUsed if allocation else "No allocation" }}{% if allocation %}/{{ allocation.breakHours }}{% endif %} Hours

-

{{ currentTerm.termName if currentTerm else "No open term" }}

+

{{ currentTerm.termName.replace("AY", "Term") if currentTerm else "No open term" }}

{{ totalPositionsUsed if allocation else "No allocation" }}{% if allocation %}/{{ totalPositionsAllocated }}{% endif %} Positions

{% if allocation %} @@ -68,9 +68,6 @@

{{ breakHoursUsed if allocation else "No allocation" }}{% if allocation %}/{ Manage Allocations - - Request Allocation -

From 747a75e68cc47de79763672d92ae0ff72e8f1a24 Mon Sep 17 00:00:00 2001 From: rukwashai Date: Tue, 7 Jul 2026 14:39:07 -0400 Subject: [PATCH 54/72] Add Primary/Secondary titles above the hour-band breakdown lists --- app/templates/main/departmentPortal.html | 28 ++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 011c80152..0208be474 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -45,17 +45,23 @@

{{ currentTerm.termName.replace("AY", "Term") if currentTerm else "No open t

{{ totalPositionsUsed if allocation else "No allocation" }}{% if allocation %}/{{ totalPositionsAllocated }}{% endif %} Positions

{% if allocation %} -
-
    -
  • 10 Hour - {{ allocationBands.primary_10.used }}/{{ allocationBands.primary_10.allocated }}
  • -
  • 12 Hour - {{ allocationBands.primary_12.used }}/{{ allocationBands.primary_12.allocated }}
  • -
  • 15 Hour - {{ allocationBands.primary_15.used }}/{{ allocationBands.primary_15.allocated }}
  • -
  • 20 Hour - {{ allocationBands.primary_20.used }}/{{ allocationBands.primary_20.allocated }}
  • -
-
    -
  • 5 Hour - {{ allocationBands.secondary_5.used }}/{{ allocationBands.secondary_5.allocated }}
  • -
  • 10 Hour - {{ allocationBands.secondary_10.used }}/{{ allocationBands.secondary_10.allocated }}
  • -
+
+
+

Primary

+
    +
  • 10 Hour - {{ allocationBands.primary_10.used }}/{{ allocationBands.primary_10.allocated }}
  • +
  • 12 Hour - {{ allocationBands.primary_12.used }}/{{ allocationBands.primary_12.allocated }}
  • +
  • 15 Hour - {{ allocationBands.primary_15.used }}/{{ allocationBands.primary_15.allocated }}
  • +
  • 20 Hour - {{ allocationBands.primary_20.used }}/{{ allocationBands.primary_20.allocated }}
  • +
+
+
+

Secondary

+
    +
  • 5 Hour - {{ allocationBands.secondary_5.used }}/{{ allocationBands.secondary_5.allocated }}
  • +
  • 10 Hour - {{ allocationBands.secondary_10.used }}/{{ allocationBands.secondary_10.allocated }}
  • +
+
{% endif %}
From fd01b329890438b066069987c7ec9134a59f527e Mon Sep 17 00:00:00 2001 From: Dayton Conwell Date: Tue, 7 Jul 2026 18:39:24 +0000 Subject: [PATCH 55/72] attempting to get back end communication --- app/controllers/main_routes/main_routes.py | 25 ++++++++++++++++++++++ app/templates/main/departmentPortal.html | 4 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 7fc414b75..1face5726 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -2,6 +2,7 @@ from peewee import JOIN, DoesNotExist from functools import reduce import operator +from app.models.allocation import Allocation from app.models.department import Department from app.models.supervisor import Supervisor from app.models.supervisorDepartment import SupervisorDepartment @@ -167,3 +168,27 @@ def submitToBanner(formHistoryId): return "Form successfully submitted to Banner.", 200 else: return "Submitting to Banner failed.", 500 + +@main_bp.route('/department///viewallocations', methods=['GET']) +def ViewAllocations(org, account): + + try: + dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) + except DoesNotExist: + return render_template('errors/404.html'), 404 + + try: + term = Term.get(Term.termState == True) + except DoesNotExist: + return render_template('errors/404.html'), 404 + + allocation = (Allocation + .select(Allocation, Term) + .join(Term) + .where(Allocation.department == dept, Allocation.termCode == term)) + + return render_template('main/viewAllocations.html', + department = dept, + department_name = dept.DEPT_NAME, + allocations = allocation,) + diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 06d1e837c..787939829 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -27,7 +27,7 @@

{% if department %} {{department.DEPT_NAME}} Portal {% e {% if department %} -
+
@@ -138,7 +138,7 @@

Positions

{% endif %} -{% endblock %}\ +{% endblock %} From e3572c5e8942355b615ff2290df6cee651252b76 Mon Sep 17 00:00:00 2001 From: Dayton Conwell Date: Tue, 7 Jul 2026 21:30:49 +0000 Subject: [PATCH 56/72] made real data show up on card and changed demo data to work --- app/controllers/main_routes/main_routes.py | 36 ++++++++++++---------- app/models/allocation.py | 2 +- app/static/js/departmentPortal.js | 1 + app/templates/main/departmentPortal.html | 15 +++++---- database/demo_data.py | 2 +- 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index f95ac60cd..a3aa58999 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -76,16 +76,23 @@ def departmentPortal(org=None,account=None): staff = Tracy().getSupervisors() supervisors = [] - + try: + allocation = Allocation.select(Allocation, Term).join(Term).where(Allocation.department == dept, Allocation.termCode == g.openTerm).get() + except DoesNotExist: + allocation = None + term = g.openTerm.termName + ViewAllocations(org, account) for i in staff: if i.ORG == org: supervisors.append(i.FIRST_NAME + " " + i.LAST_NAME + " (" + i.EMAIL + ")") - return render_template('main/departmentPortal.html', departments = departments, department = dept, positions = positions, - supervisors = supervisors + supervisors = supervisors, + # department_name = dept.DEPT_NAME, + allocation = allocation, + term = term ) @main_bp.route('/department///managepositions', methods=['GET']) @@ -171,26 +178,23 @@ def submitToBanner(formHistoryId): else: return "Submitting to Banner failed.", 500 -@main_bp.route('/department///viewallocations', methods=['GET']) +@main_bp.route('/department//', methods=['GET']) def ViewAllocations(org, account): - + try: dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) except DoesNotExist: return render_template('errors/404.html'), 404 - try: - term = Term.get(Term.termState == True) - except DoesNotExist: - return render_template('errors/404.html'), 404 - allocation = (Allocation - .select(Allocation, Term) - .join(Term) - .where(Allocation.department == dept, Allocation.termCode == term)) - - return render_template('main/viewAllocations.html', + allocation = Allocation.select(Allocation, Term).join(Term).where(Allocation.department == dept, Allocation.termCode == g.openTerm) + print(g.openTerm, '*********************************************************') + term = g.openTerm.termName + print(term, type(term), '*********************************************************') + return render_template('main/departmentPortal.html', department = dept, department_name = dept.DEPT_NAME, - allocations = allocation,) + allocation = allocation, + term = term + ) diff --git a/app/models/allocation.py b/app/models/allocation.py index ddd2084d7..9f333e0da 100644 --- a/app/models/allocation.py +++ b/app/models/allocation.py @@ -8,7 +8,7 @@ class Allocation(baseModel): department = ForeignKeyField(Department) isApproved = BooleanField(default=False) approvedOn = DateField() - approvedBy = ForeignKeyField(Supervisor) + approvedBy = CharField() justification = TextField() primary_10 = IntegerField() primary_12 = IntegerField() diff --git a/app/static/js/departmentPortal.js b/app/static/js/departmentPortal.js index cb2023a3a..d8dbbc84e 100644 --- a/app/static/js/departmentPortal.js +++ b/app/static/js/departmentPortal.js @@ -2,5 +2,6 @@ $(document).ready(function() { $("#selectedDepartment").on("change",function() { deptData = $(this).find('option:selected').data(); window.location = `/department/${deptData.org}/${deptData.account}`; + }); }); diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 787939829..6cf810250 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -23,7 +23,6 @@

{% if department %} {{department.DEPT_NAME}} Portal {% e "{{d.DEPT_NAME}} ({{d.ORG}}-{{d.ACCOUNT}}) ">{{d.DEPT_NAME}} {% endfor %} -

{% if department %} @@ -41,18 +40,18 @@

Allocations

-

AY 26/27

15/20 Positions

+

{{ term }}

15/ {{allocation.primary_10 + allocation.primary_12 + allocation.primary_15 + allocation.primary_20 + allocation.secondary_5 + allocation.secondary_10}} Positions

    -
  • 10 Hour - 2/2
  • -
  • 12 Hour - 3/3
  • -
  • 15 Hour - 5/5
  • -
  • 20 Hour - 5/5
  • +
  • 10 Hour - 2/{{allocation.primary_10}}
  • +
  • 12 Hour - 3/{{allocation.primary_12}}
  • +
  • 15 Hour - 5/{{allocation.primary_15}}
  • +
  • 20 Hour - 5/{{allocation.primary_20}}
    -
  • 5 Hour - 2/2
  • -
  • 10 Hour - 3/3
  • +
  • 5 Hour - 2/{{allocation.secondary_5}}
  • +
  • 10 Hour - 3/{{allocation.secondary_10}}
diff --git a/database/demo_data.py b/database/demo_data.py index 4f3a5e72c..a9355946f 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -734,7 +734,7 @@ "breakHours": 750, }, { - "termCode": 202400, + "termCode": 202500, "department": 1, "isApproved": False, "approvedOn": None, From 0d64daf5252acab74dd7c997e9ca7328c007b1db Mon Sep 17 00:00:00 2001 From: rukwashai Date: Wed, 8 Jul 2026 11:14:25 -0400 Subject: [PATCH 57/72] Add allocation warning to pending LSF approval modal (#622) Extract allocation logic into app/logic/allocation.py (getAllocationSummary, getAllocationWarning), wire it into modal_approval_and_denial_data() to show a per-department warning box in the approval confirmation modal, and fix demo data so students/supervisors are marked active (needed for the approval checkbox to render at all). --- app/controllers/main_routes/main_routes.py | 65 ++--------- app/logic/allPendingForms.py | 20 +++- app/logic/allocation.py | 106 ++++++++++++++++++ app/static/js/allPendingForms.js | 23 +++- app/templates/snips/pendingApprovalModal.html | 1 + database/demo_data.py | 2 + 6 files changed, 153 insertions(+), 64 deletions(-) create mode 100644 app/logic/allocation.py diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 3393758a2..ac48a1c4a 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -1,16 +1,12 @@ from flask import render_template, request, json, redirect, url_for, send_file, g, flash, jsonify -from peewee import JOIN, DoesNotExist, fn +from peewee import JOIN, DoesNotExist from functools import reduce import operator -from app.models.allocation import Allocation from app.models.department import Department from app.models.supervisor import Supervisor from app.models.supervisorDepartment import SupervisorDepartment from app.models.student import Student -from app.models.laborStatusForm import LaborStatusForm from app.models.formHistory import FormHistory -from app.models.term import Term -from app.models.allocation import Allocation from app.controllers.admin_routes.allPendingForms import checkAdjustment from app.controllers.main_routes import main_bp from app.logic.download import CSVMaker, saveFormSearchResult, retrieveFormSearchResult @@ -19,6 +15,7 @@ from app.logic.getTableData import getDatatableData from app.logic.banner import Banner from app.logic.tracy import Tracy +from app.logic.allocation import getAllocationSummary @main_bp.route('/logout', methods=['GET']) def triggerLogout(): @@ -82,64 +79,18 @@ def departmentPortal(org=None,account=None): if i.ORG == org: supervisors.append(i.FIRST_NAME + " " + i.LAST_NAME + " (" + i.EMAIL + ")") - allocation = None - allocationBands = None - totalPositionsAllocated = None - totalPositionsUsed = None - breakHoursUsed = None - if dept and g.openTerm: - allocation = Allocation.get_or_none(Allocation.department == dept, Allocation.termCode == g.openTerm) - if allocation: - bandFields = [ - ('primary_10', 'Primary', 10), - ('primary_12', 'Primary', 12), - ('primary_15', 'Primary', 15), - ('primary_20', 'Primary', 20), - ('secondary_5', 'Secondary', 5), - ('secondary_10', 'Secondary', 10), - ] - allocationBands = {} - for fieldName, jobType, hours in bandFields: - used = (LaborStatusForm - .select() - .join(FormHistory, on=(FormHistory.formID == LaborStatusForm.laborStatusFormID)) - .where(LaborStatusForm.department == dept, - LaborStatusForm.termCode == g.openTerm, - LaborStatusForm.jobType == jobType, - LaborStatusForm.weeklyHours == hours, - FormHistory.historyType == "Labor Status Form", - ~(FormHistory.status % "Denied%")) - .distinct() - .count()) - allocationBands[fieldName] = {'used': used, 'allocated': getattr(allocation, fieldName)} - - totalPositionsAllocated = sum(band['allocated'] for band in allocationBands.values()) - totalPositionsUsed = sum(band['used'] for band in allocationBands.values()) - - # Break hours are tracked on separate break-term rows (e.g. Thanksgiving Break) - # that share the same academic year prefix as the open AY term. - yearPrefix = str(g.openTerm.termCode)[:-2] - breakTermCodes = [t.termCode for t in Term.select().where(Term.isBreak == True) - if str(t.termCode).startswith(yearPrefix)] - breakHoursUsed = (LaborStatusForm - .select(fn.SUM(LaborStatusForm.contractHours)) - .join(FormHistory, on=(FormHistory.formID == LaborStatusForm.laborStatusFormID)) - .where(LaborStatusForm.department == dept, - LaborStatusForm.termCode.in_(breakTermCodes), - FormHistory.historyType == "Labor Status Form", - ~(FormHistory.status % "Denied%")) - .scalar()) or 0 + allocationSummary = getAllocationSummary(dept, g.openTerm) return render_template('main/departmentPortal.html', departments = departments, department = dept, positions = positions, supervisors = supervisors, - allocation = allocation, - allocationBands = allocationBands, - totalPositionsAllocated = totalPositionsAllocated, - totalPositionsUsed = totalPositionsUsed, - breakHoursUsed = breakHoursUsed, + allocation = allocationSummary['allocation'], + allocationBands = allocationSummary['allocationBands'], + totalPositionsAllocated = allocationSummary['totalPositionsAllocated'], + totalPositionsUsed = allocationSummary['totalPositionsUsed'], + breakHoursUsed = allocationSummary['breakHoursUsed'], currentTerm = g.openTerm) @main_bp.route('/department///managepositions', methods=['GET']) diff --git a/app/logic/allPendingForms.py b/app/logic/allPendingForms.py index a9d4a3bd2..479eb9997 100644 --- a/app/logic/allPendingForms.py +++ b/app/logic/allPendingForms.py @@ -1,6 +1,6 @@ import json from datetime import date -from flask import jsonify +from flask import jsonify, g from app.models.formHistory import FormHistory from app.models.status import Status from app.logic.banner import Banner @@ -14,6 +14,7 @@ from app.models.overloadForm import OverloadForm from app.models.notes import Notes from app.login_manager import DoesNotExist, render_template +from app.logic.allocation import getAllocationWarning def saveStatus(new_status, formHistoryIds, currentUser): @@ -196,9 +197,11 @@ def laborAdminOverloadApproval(rsp, historyForm, status, currentUser, currentDat # extract data from the database to populate pending form approval modal def modal_approval_and_denial_data(formHistoryIdList): - ''' This method grabs the data that populated the on approve modal for lsf''' + ''' This method grabs the data that populated the on approve modal for lsf, + plus an over-allocation warning per unique department among the selected forms. ''' details_list = [] + allocationWarningsByDept = {} for fhID in formHistoryIdList: formHistory = FormHistory.get(FormHistory.formHistoryID == fhID) lsf = formHistory.formID @@ -208,7 +211,8 @@ def modal_approval_and_denial_data(formHistoryIdList): supervisorName = f"{lsf.supervisor.FIRST_NAME} {lsf.supervisor.LAST_NAME}" weeklyHours = lsf.weeklyHours contractHours = lsf.contractHours - deptName = lsf.department.DEPT_NAME + dept = lsf.department + deptName = dept.DEPT_NAME if formHistory.adjustedForm: match formHistory.adjustedForm.fieldAdjusted: @@ -223,11 +227,17 @@ def modal_approval_and_denial_data(formHistoryIdList): case "contractHours": contractHours = formHistory.adjustedForm.newValue case "department": - deptName = Department.get(Department.ORG==formHistory.adjustedForm.newValue).DEPT_NAME + dept = Department.get(Department.ORG==formHistory.adjustedForm.newValue) + deptName = dept.DEPT_NAME details_list.append([studentName, deptName, position, str(weeklyHours),str(contractHours), supervisorName]) - return details_list + if dept.departmentID not in allocationWarningsByDept: + warning = getAllocationWarning(dept, g.openTerm) + if warning: + allocationWarningsByDept[dept.departmentID] = warning + + return {"details": details_list, "allocationWarnings": list(allocationWarningsByDept.values())} def financialAidSAASOverloadApproval(historyForm, rsp, status, currentUser, currentDate): diff --git a/app/logic/allocation.py b/app/logic/allocation.py new file mode 100644 index 000000000..ce9525220 --- /dev/null +++ b/app/logic/allocation.py @@ -0,0 +1,106 @@ +from peewee import fn +from app.models.allocation import Allocation +from app.models.laborStatusForm import LaborStatusForm +from app.models.formHistory import FormHistory +from app.models.term import Term + +# Each entry is (Allocation field name, LaborStatusForm.jobType, LaborStatusForm.weeklyHours) +ALLOCATION_BAND_FIELDS = [ + ('primary_10', 'Primary', 10), + ('primary_12', 'Primary', 12), + ('primary_15', 'Primary', 15), + ('primary_20', 'Primary', 20), + ('secondary_5', 'Secondary', 5), + ('secondary_10', 'Secondary', 10), +] + + +def getAllocationSummary(dept, term): + """ + Returns a dict describing a department's allocation vs. actual usage for the given term: + - allocation: the Allocation row for this dept/term, or None if none exists + - allocationBands: {fieldName: {'used': int, 'allocated': int}} per hour-band, or None + - totalPositionsAllocated / totalPositionsUsed: ints, or None + - breakHoursUsed: int, or None + 'used' counts are non-denied LaborStatusForms, matching the same filter pattern + used elsewhere in the app (see app/logic/statusFormFunctions.py). + """ + summary = { + 'allocation': None, + 'allocationBands': None, + 'totalPositionsAllocated': None, + 'totalPositionsUsed': None, + 'breakHoursUsed': None, + } + + if not (dept and term): + return summary + + allocation = Allocation.get_or_none(Allocation.department == dept, Allocation.termCode == term) + summary['allocation'] = allocation + if not allocation: + return summary + + allocationBands = {} + for fieldName, jobType, hours in ALLOCATION_BAND_FIELDS: + used = (LaborStatusForm + .select() + .join(FormHistory, on=(FormHistory.formID == LaborStatusForm.laborStatusFormID)) + .where(LaborStatusForm.department == dept, + LaborStatusForm.termCode == term, + LaborStatusForm.jobType == jobType, + LaborStatusForm.weeklyHours == hours, + FormHistory.historyType == "Labor Status Form", + ~(FormHistory.status % "Denied%")) + .distinct() + .count()) + allocationBands[fieldName] = {'used': used, 'allocated': getattr(allocation, fieldName)} + + summary['allocationBands'] = allocationBands + summary['totalPositionsAllocated'] = sum(band['allocated'] for band in allocationBands.values()) + summary['totalPositionsUsed'] = sum(band['used'] for band in allocationBands.values()) + + # Break hours are tracked on separate break-term rows (e.g. Thanksgiving Break) + # that share the same academic year prefix as the given AY term. + yearPrefix = str(term.termCode)[:-2] + breakTermCodes = [t.termCode for t in Term.select().where(Term.isBreak == True) + if str(t.termCode).startswith(yearPrefix)] + summary['breakHoursUsed'] = (LaborStatusForm + .select(fn.SUM(LaborStatusForm.contractHours)) + .join(FormHistory, on=(FormHistory.formID == LaborStatusForm.laborStatusFormID)) + .where(LaborStatusForm.department == dept, + LaborStatusForm.termCode.in_(breakTermCodes), + FormHistory.historyType == "Labor Status Form", + ~(FormHistory.status % "Denied%")) + .scalar()) or 0 + + return summary + + +def getAllocationWarning(dept, term): + """ + Returns a summary dict for displaying an over-allocation warning for the given + department/term (e.g. in the pending-LSF approval modal), or None if there's no + allocation on record for that department/term to compare against. + + Note: 'used' counts (from getAllocationSummary) include Pending as well as + Approved forms, so a form currently Pending already occupies a slot here - + these numbers already reflect what utilization would be once it's approved. + """ + summary = getAllocationSummary(dept, term) + if not summary['allocation']: + return None + + positionsRemaining = summary['totalPositionsAllocated'] - summary['totalPositionsUsed'] + breakHoursRemaining = summary['allocation'].breakHours - summary['breakHoursUsed'] + + return { + 'departmentName': dept.DEPT_NAME, + 'totalPositionsAllocated': summary['totalPositionsAllocated'], + 'totalPositionsUsed': summary['totalPositionsUsed'], + 'positionsRemaining': positionsRemaining, + 'breakHoursAllocated': summary['allocation'].breakHours, + 'breakHoursUsed': summary['breakHoursUsed'], + 'breakHoursRemaining': breakHoursRemaining, + 'isOverAllocated': positionsRemaining < 0 or breakHoursRemaining < 0, + } diff --git a/app/static/js/allPendingForms.js b/app/static/js/allPendingForms.js index ae79740e4..d0049423b 100644 --- a/app/static/js/allPendingForms.js +++ b/app/static/js/allPendingForms.js @@ -87,8 +87,8 @@ function insertApprovals(laborHistoryId = null) { contentType: 'application/json', success: function(response) { if (response) { - var returned_details = response; - updateApproveTableData(returned_details); + updateApproveTableData(response.details); + updateAllocationWarnings(response.allocationWarnings); } } }); @@ -112,6 +112,24 @@ function updateApproveTableData(returned_details) { } } +// Shows a non-blocking allocation warning per department represented among the +// selected forms, so admins can see the impact of approval before confirming. +function updateAllocationWarnings(allocationWarnings) { + if (!allocationWarnings) { return; } + for (var i = 0; i < allocationWarnings.length; i++) { + var w = allocationWarnings[i]; + var alertClass = w.isOverAllocated ? 'alert-danger' : 'alert-info'; + var html = ''; + $('#allocationWarnings').append(html); + } +} + $('#approvalModal').on('hidden.bs.modal', function () {// Makes the close functionality work when clicking outside of the modal approvalModalClose(); @@ -120,6 +138,7 @@ $('#approvalModal').on('hidden.bs.modal', function () {// Makes the close functi function approvalModalClose(){// on close of approval modal we are clearing the table to prevent duplicate data. $('#classTableBody').empty(); + $('#allocationWarnings').empty(); labor_details_ids = [] // emptying the list, becuase otherwise will cause duplicate data. } diff --git a/app/templates/snips/pendingApprovalModal.html b/app/templates/snips/pendingApprovalModal.html index 33ff1c992..66421353e 100644 --- a/app/templates/snips/pendingApprovalModal.html +++ b/app/templates/snips/pendingApprovalModal.html @@ -10,6 +10,7 @@