From 56bbcdb29e79facf98ca8dc2500cc75201f39d4d Mon Sep 17 00:00:00 2001 From: conwelld Date: Wed, 22 Jul 2026 14:05:36 -0400 Subject: [PATCH 1/4] made new branch without other people's code should be ready to pr --- app/controllers/main_routes/main_routes.py | 45 +++++++++++++------- app/static/css/managePositions.css | 33 +++++++++++++++ app/static/js/managePositions.js | 9 ++++ app/templates/main/managePositions.html | 48 ++++++++++++++++++++++ 4 files changed, 120 insertions(+), 15 deletions(-) create mode 100644 app/static/css/managePositions.css create mode 100644 app/static/js/managePositions.js create mode 100644 app/templates/main/managePositions.html diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 0a2f21e4..65385502 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -63,26 +63,41 @@ def departmentPortal(org=None,account=None): else: departments = list(getDepartmentsForSupervisor(g.currentUser).order_by(Department.isActive.desc(), Department.DEPT_NAME.asc())) + if dept and not g.currentUser.isLaborAdmin and dept.departmentID not in [d.departmentID for d in departments]: + return render_template('errors/403.html'), 403 + + positionsList, posURL = getActivePositions(dept) + return render_template('main/departmentPortal.html', departments = departments, department = dept) -@main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST']) -def addUserToDept(): - userDeptData = request.form - supervisorDeptRecord = SupervisorDepartment.get_or_none(supervisor = userDeptData['supervisorID'], department = userDeptData['departmentID']) - try: - if supervisorDeptRecord: - return "False" - - else: - SupervisorDepartment.create(supervisor=userDeptData['supervisorID'], department=userDeptData['departmentID']) - return "True" - - except Exception as e: - print(f'Could not add user to department: {e}') - return "", 500 +@main_bp.route('/department///positions', methods=['GET']) +def managePositions(org, account): + currentUser = require_login() + if not currentUser or not currentUser.supervisor: + return render_template('errors/403.html'), 403 + try: + dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) + except DoesNotExist: + return render_template('errors/404.html'), 404 + + if not currentUser.isLaborAdmin: + allowedDepartmentIds = [d.departmentID for d in getDepartmentsForSupervisor(currentUser)] + if dept.departmentID not in allowedDepartmentIds: + return render_template('errors/403.html'), 403 + + positions = (PositionHistory.select() + .where((PositionHistory.department == dept) & + (PositionHistory.status == "Active")) + .order_by(PositionHistory.positionTitle.asc())) + + return render_template('main/managePositions.html', + department = dept, + department_name = dept.DEPT_NAME, + positions = positions + ) @main_bp.route('/supervisorPortal/download', methods=['POST']) def downloadSupervisorPortalResults(): ''' diff --git a/app/static/css/managePositions.css b/app/static/css/managePositions.css new file mode 100644 index 00000000..345b9c65 --- /dev/null +++ b/app/static/css/managePositions.css @@ -0,0 +1,33 @@ +.width-12{ + width:12%; +} +.margin-top-10{ + margin-top:-25px; +} +*{ + /* outline:solid 1px lime; */ + margin:0; + padding:0; + box-sizing:border-box; +} + +.department-header{ + padding:1%; + margin-top:-20px; +} + +td{ + text-align:center !important; +}/* managePositions.css */ + +.position-management .width-12 { + width: 12%; +} + +.position-management h1 { + margin-top: 10px; +} + +.position-management td { + text-align: center; +} \ No newline at end of file diff --git a/app/static/js/managePositions.js b/app/static/js/managePositions.js new file mode 100644 index 00000000..3f647389 --- /dev/null +++ b/app/static/js/managePositions.js @@ -0,0 +1,9 @@ +$(document).ready(function () { + $('#positionTable').DataTable({ + pageLength: 25, + columnDefs: [ + { className: 'dt-head-center', targets: '_all' }, + { orderable: false, targets: [4,4 ] } + ] + }); +}); \ No newline at end of file diff --git a/app/templates/main/managePositions.html b/app/templates/main/managePositions.html new file mode 100644 index 00000000..5a54514c --- /dev/null +++ b/app/templates/main/managePositions.html @@ -0,0 +1,48 @@ +{% extends "base.html" %} + +{% block styles %} +{{ super() }} + + +{% endblock %} + +{% block scripts %} +{{ super() }} + + +{% endblock %} + +{% block app_content %} +
+

{{ department_name }} Positions

+ +
+ + + + + + + + + + + + {% for position in positions %} + + + + + + + + {% endfor %} + +
PositionWLSLast Revision DateView Position DescriptionEdit Position Description
{{ position.positionTitle }} {{ position.positionCode }}{{ position.wls }}{{ position.revisionDate }} + + + +
+
+
+{% endblock %} \ No newline at end of file From 8a34d2db507a19479d006f426a0604e4b2819fe0 Mon Sep 17 00:00:00 2001 From: conwelld Date: Wed, 22 Jul 2026 16:37:12 -0400 Subject: [PATCH 2/4] added demo data and fixed positionTitle key --- app/models/positionHistory.py | 1 + database/demo_data.py | 81 +++++++++++++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/app/models/positionHistory.py b/app/models/positionHistory.py index 51467075..9a248aac 100644 --- a/app/models/positionHistory.py +++ b/app/models/positionHistory.py @@ -2,6 +2,7 @@ from app.models.department import Department class PositionHistory(baseModel): + positionTitle = CharField() positionCode = CharField() department = ForeignKeyField(Department) status = CharField() diff --git a/database/demo_data.py b/database/demo_data.py index de604762..57a50db5 100644 --- a/database/demo_data.py +++ b/database/demo_data.py @@ -751,48 +751,121 @@ ############################# positionHistory = [ - { + { + "positionTitle": "Student Programmer", "positionCode": "S61407", "status": "Active", "wls": 1, "revisionDate": f"2025-07-01", + "revisionDate": f"2026-07-01", "description": "", "department": 1 }, { + "positionTitle": "Research Associate", "positionCode": "S61408", "status": "Active", "wls": 2, "revisionDate": f"2025-09-01", + "revisionDate": f"2026-09-01", "description": "", "department": 1 }, { + "positionTitle": "Labor Workers", "positionCode": "S61409", "status": "Active", "wls": 3, "revisionDate": f"2025-07-01", + "revisionDate": f"2026-07-01", "description": "", "department": 1 }, { + "positionTitle": "Teaching Associate", "positionCode": "S61411", "status": "Active", "wls":3, "revisionDate" : f"2025-01-01", + "revisionDate" : f"2026-01-01", "description": "", "department" : 1 - }, - { + }, + { + "positionTitle": "Teaching Associate", "positionCode": "S61410", "status": "Inactive", "wls":2, "revisionDate" : f"2025-01-01", + "revisionDate" : f"2026-01-01", + "description": "", + "department" : 3 + }, + { + "positionTitle": "Teaching Associate", + "positionCode": "S61410", + "status": "Active", + "wls":2, + "revisionDate" : f"2026-03-29", + "description": "", + "department" : 3 + }, + { + "positionTitle": "DUMMY POSITION", + "positionCode": "S12345", + "status": "Active", + "wls":3, + "revisionDate" : f"2026-01-23", "description": "", "department" : 1 - }, + }, + { + "positionTitle": "Junior Data Analyst", + "positionCode": "S39568", + "status": "Active", + "wls":4, + "revisionDate" : f"2026-01-31", + "description": "", + "department" : 1 + }, + { + "positionTitle": "Student Manager", + "positionCode": "S74933", + "status": "Active", + "wls":5, + "revisionDate" : f"2026-04-01", + "description": "", + "department" : 1 + }, + { + "positionTitle": "IT Technician", + "positionCode": "S94932", + "status": "Active", + "wls":6, + "revisionDate" : f"2026-05-03", + "description": "", + "department" : 1 + }, + { + "positionTitle": "Human code generator", + "positionCode": "S22222", + "status": "Active", + "wls":1, + "revisionDate" : f"2026-05-03", + "description": "", + "department" : 1 + }, + { + "positionTitle": "Senior Software Engineer", + "positionCode": "S00000", + "status": "Active", + "wls":6, + "revisionDate" : f"2026-05-03", + "description": "", + "department" : 1 + } ] PositionHistory.insert_many(positionHistory).on_conflict_replace().execute() From c295e4dfff831e5a7cc8400311bf3b174beb2838 Mon Sep 17 00:00:00 2001 From: conwelld Date: Wed, 22 Jul 2026 16:43:05 -0400 Subject: [PATCH 3/4] added positionHistory call --- app/controllers/main_routes/main_routes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 65385502..1971c9b2 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.models.positionHistory import PositionHistory @main_bp.route('/logout', methods=['GET']) def triggerLogout(): From 276453f8b012daad2556bffc00bfe334bd0fec04 Mon Sep 17 00:00:00 2001 From: conwelld Date: Wed, 22 Jul 2026 16:46:35 -0400 Subject: [PATCH 4/4] fixed department portal page --- app/controllers/main_routes/main_routes.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 1971c9b2..95d9b2d7 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -67,11 +67,10 @@ def departmentPortal(org=None,account=None): if dept and not g.currentUser.isLaborAdmin and dept.departmentID not in [d.departmentID for d in departments]: return render_template('errors/403.html'), 403 - positionsList, posURL = getActivePositions(dept) - return render_template('main/departmentPortal.html', departments = departments, - department = dept) + department = dept, + ) @main_bp.route('/department///positions', methods=['GET']) def managePositions(org, account):