Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
9d4acbf
Started working on HTML design
zhytkovd Jul 2, 2026
8deecb5
Finished initial design of the department page
zhytkovd Jul 4, 2026
9a14e6d
Fixed current year button position
zhytkovd Jul 6, 2026
6a5fec7
centered data in the table and div container
zhytkovd Jul 6, 2026
20e8718
Merge branch 'PeeWeeAttribute' into dep_portal_ad
ACBerea Jul 6, 2026
cde15a7
Merge branch 'development' into dep_portal_ad
zhytkovd Jul 6, 2026
7341b74
Fixed actions button: made it similar to the other dropdown menus
zhytkovd Jul 7, 2026
25b6251
Finished requested UI changes: renaming some elements
zhytkovd Jul 7, 2026
c6c7293
Added brake hours from the database to the UI
zhytkovd Jul 7, 2026
636dd71
Fixed brake hours given: removed double loop and filtered by AY
zhytkovd Jul 8, 2026
b615974
Added accurate academic year to manage_department.py by allocating te…
ACBerea Jul 8, 2026
ac35d1e
Changed test data to include break hours in the:changed them to secon…
zhytkovd Jul 9, 2026
d68e73f
Created a separate function for calculating total break hours used by…
zhytkovd Jul 9, 2026
d87910c
Began implementing logic for current year. Committing now for merging…
ACBerea Jul 10, 2026
b900ff1
Merge branch 'department-portal-base' into dep_portal_ad_ManageDepart…
ACBerea Jul 10, 2026
22d77f9
Fixed dummy data issues for testing purposes.
ACBerea Jul 10, 2026
e977ecb
Merge branch 'department-portal-base' into dep_portal_ad_ManageDepart…
ACBerea Jul 10, 2026
54021ef
Fixed dummy data error regarding left over current_year variable by r…
ACBerea Jul 10, 2026
56bd437
Added new demo data and improved sql joins.
zhytkovd Jul 10, 2026
978b098
Applied break hours used/give to HTML and fixed extracted data for us…
ACBerea Jul 10, 2026
6119490
Fixed button color for actions button to match other versons on the …
ACBerea Jul 13, 2026
20aa6e8
Added demo data for inactive departments in demo_data.py
ACBerea Jul 13, 2026
5747cd2
Changed isFinal from False to True for some demo-data in demo-data.py…
ACBerea Jul 13, 2026
11dd7ed
Added current year dropdown
zhytkovd Jul 13, 2026
d1844b7
Added functionality to Allocation Approval Status. The status button …
ACBerea Jul 13, 2026
f2d9266
Merge branch 'department-portal-base' of https://github.com/BCStudent…
ACBerea Jul 13, 2026
dfcf6f7
Fixed primary and secondary positions to use database information and…
ACBerea Jul 13, 2026
f90dd7e
Merge branch 'department-portal-base' of https://github.com/BCStudent…
ACBerea Jul 13, 2026
1796ba8
Fixed the bug with the active/inactive departments and changed the po…
zhytkovd Jul 13, 2026
86683f9
Fixed the bug with the active/inactive departments and changed the po…
zhytkovd Jul 13, 2026
582a225
Fixed Inactive Departments appearing outside of the inactive departme…
ACBerea Jul 13, 2026
c5d61d1
Changed the Allocation Approval Status to a label instead of a button…
ACBerea Jul 13, 2026
2417c95
Added additional demo data for testing for positions on the manage de…
ACBerea Jul 13, 2026
9daec6b
Fixed allocation approval status bittons
zhytkovd Jul 14, 2026
28dfb5d
Improved year dropdown label text and commented out print statements.
ACBerea Jul 14, 2026
f87ccce
Merge branch 'department-portal-base' of https://github.com/BCStudent…
ACBerea Jul 14, 2026
924c56e
Merge branch 'department-portal-base' of https://github.com/BCStudent…
ACBerea Jul 14, 2026
fb2356e
Merge branch 'department-portal-base' into dep_portal_ad_ManageDepart…
MImran2002 Jul 14, 2026
4ee93d2
Merge branch 'dep_portal_ad_ManageDepartments' of https://github.com/…
ACBerea Jul 14, 2026
f6fa196
Fixed breakHourByDepartments issue and adjusted duplicate dummy data.
ACBerea Jul 14, 2026
9900bd4
Added an empty test suite for the queries in manageDepartments.py
ACBerea Jul 15, 2026
c18f8a6
Moved queries from manage_departments.py routing file to manageDepart…
ACBerea Jul 15, 2026
acfda64
Merge branch 'department-portal-base' of https://github.com/BCStudent…
ACBerea Jul 15, 2026
0cb3918
Reordered functions in manageDepartments.py
ACBerea Jul 15, 2026
ad67b06
Began working on test suite for Manage Departments. Specifically desi…
ACBerea Jul 15, 2026
16c4cf3
Changed the accademic year to reflect the accurate currentTerm.
ACBerea Jul 16, 2026
90891ef
Removed --skipssl
ACBerea Jul 20, 2026
7cef723
Added terms for fall, spring, summer, previous, and next. These work …
ACBerea Jul 20, 2026
9a3ca62
Commented out seasonal terms for testing and added the proper terms t…
ACBerea Jul 20, 2026
bbc95b4
Merge remote-tracking branch 'origin/department-portal-base' into dep…
ACBerea Jul 20, 2026
d77c410
Improved termManagement.py to all for creating terms via a list based…
ACBerea Jul 21, 2026
bd5c4e6
Moved some of the code into logic + replaced eval() with get_json() i…
ArtemKurasov Jul 21, 2026
f03cc59
Users can now choose the previous and the following years
ArtemKurasov Jul 21, 2026
3c67429
Moved more functionality into logic + Deleted/Commented out all print…
ArtemKurasov Jul 22, 2026
5558a21
Changed buttons to be responsive relative to the screen size
zhytkovd Jul 22, 2026
5a93dfd
Merge branch 'dep_portal_ad_ManageDepartments' of https://github.com/…
zhytkovd Jul 22, 2026
0fd5459
Tried adding tests to the Manage Departments page
ArtemKurasov Jul 22, 2026
15358a4
Merge remote-tracking branch 'refs/remotes/origin/dep_portal_ad_Manag…
ArtemKurasov Jul 22, 2026
0de602b
Fixed default academic year in the url error
zhytkovd Jul 22, 2026
41e0c72
Fixed the issue with the default value of academicYear
ArtemKurasov Jul 22, 2026
0b3a970
Merge branch 'department-portal-base' into dep_portal_ad_ManageDepart…
MImran2002 Jul 27, 2026
4c88fbc
Added modals for the Annual Allocation Review and the Annual Position…
ArtemKurasov Jul 27, 2026
6828794
Merge remote-tracking branch 'refs/remotes/origin/dep_portal_ad_Manag…
ArtemKurasov Jul 27, 2026
66fa149
Added the Term dropdown + Made a lot of changes to the look of the Ma…
ArtemKurasov Jul 27, 2026
866cbf5
Added new line to table headers
zhytkovd Jul 28, 2026
2eb23e6
Added a popup for the Allocation Review button + made some minor chan…
ArtemKurasov Jul 28, 2026
d9de982
Merge branch 'department-portal-base' into dep_portal_ad_ManageDepart…
ArtemKurasov Jul 28, 2026
8f69073
Tidied up import statements + Deleted some comments
ArtemKurasov Jul 28, 2026
1319589
Cleaned up the manage_departments.py and the logic/manageDepartments.…
ArtemKurasov Jul 29, 2026
39592bb
Added tests for the generateAdjacentYears() function
ArtemKurasov Jul 29, 2026
d9dd9c5
Renamed manage_departments.py to manageDepartments.py
ArtemKurasov Jul 29, 2026
7c22a80
Started working on a separate Allocation Review Page
ArtemKurasov Jul 29, 2026
db2bcb5
Integrated the Allocation Review form into the Manage Departments pag…
ArtemKurasov Jul 30, 2026
226d3ff
Moved the styles and js code for the Allocation Review page into thei…
ArtemKurasov Jul 30, 2026
4c6c659
Made changes in accordance with Bhushan's comments
ArtemKurasov Jul 30, 2026
2184f5d
Added a popup for the Upload Allocations button + Fixed some of the l…
ArtemKurasov Jul 30, 2026
07d7496
Merge branch 'department-portal-base' into dep_portal_ad_ManageDepart…
ArtemKurasov Jul 30, 2026
f409edf
Fixed several typos
ArtemKurasov Jul 31, 2026
927651b
Changed the names of the Action Button options
ArtemKurasov Jul 31, 2026
887ecb4
Added links to the options of the Action button + updated the URL of …
ArtemKurasov Jul 31, 2026
751de1e
Merge branch 'department-portal-base' into dep_portal_ad_ManageDepart…
ArtemKurasov Aug 3, 2026
1f27acc
Merge branch 'department-portal-base' into dep_portal_ad_ManageDepart…
ArtemKurasov Aug 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/admin_routes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def injectGlobalData():
return {'currentUser': currentUser,
'lastStaticUpdate': lastStaticUpdate}

from app.controllers.admin_routes import manage_departments
from app.controllers.admin_routes import manageDepartments
from app.controllers.admin_routes import termManagement
from app.controllers.admin_routes import adminManagement
from app.controllers.admin_routes import allPendingForms
Expand Down
124 changes: 124 additions & 0 deletions app/controllers/admin_routes/manageDepartments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
from datetime import date

from flask import g, request, redirect, jsonify, abort

from app.controllers.admin_routes import *
from app.login_manager import require_login

from app.controllers.admin_routes import admin
from app.controllers.errors_routes.handlers import *

from app.models.formHistory import FormHistory
from app.models.user import *
from app.models.term import *
from app.models.department import *
from app.models.allocation import *
from app.models.laborStatusForm import *

from app.logic.manageDepartments import *



@admin.route('/admin/manageDepartments/', methods=['GET'])
@admin.route('/admin/manageDepartments/<academicYear>', methods=['GET'])
def manageDepartments(academicYear = None):
"""
Returns the Manage Departments page, which allows the admin to view all the departments
and their allocations.
"""

# Checking Admin Rights
currentUser = require_login()
if not currentUser: # If the current user is not logged in
return render_template('errors/403.html')
if not currentUser.isLaborAdmin:
if currentUser.student:
return redirect('/laborHistory/' + currentUser.student.ID)
elif currentUser.supervisor:
return render_template('errors/403.html'), 403


# The condition below may be deleted if the routing to the Manage Departments page is changed.
if academicYear == None:
academicYear = g.openTerm.termCode
else:
academicYear = int(academicYear)


currentAY, previousAY, nextAY = generateAdjacentYears(academicYear)
chosenAY = Term.get(Term.termCode == academicYear)

breakHoursByDepartment = {row["department"]: str(row["totalHours"] or 0) for row in getUsedBreakHours(chosenAY)}

activeDepartments = getActiveDepartmentsWithAllocation(chosenAY)
inactiveDepartments = Department.select().where(Department.isActive == False)

allocationStatus = {
department.departmentID: getAllocationStatus(chosenAY, department)
for department in activeDepartments
}

allSupervisors= Supervisor.select().order_by(Supervisor.LAST_NAME)

return render_template( 'admin/manageDepartments.html',
activeDepartments = activeDepartments,
inactiveDepartments = inactiveDepartments,
allSupervisors = allSupervisors,
currentAY = currentAY,
previousAY = previousAY,
nextAY = nextAY,
academicYear = chosenAY.termName,
breakHoursByDepartment = breakHoursByDepartment,
allocationStatus = allocationStatus
)



@admin.route('/admin/complianceStatus', methods=['POST'])
def complianceStatusCheck():
"""
This function changes the compliance status in the database for labor status forms.
It works in collaboration with the ajax call in manageDepartments.js
"""
try:
rsp = request.get_json()
if rsp:
department = Department.get(int(rsp['deptName']))
department.departmentCompliance = not department.departmentCompliance
department.save()
return jsonify({"Success": True})
except Exception as e:
print(e)
return jsonify({"Success": False})



@admin.route('/admin/manageDepartments/<org>/<account>/allocationReview', methods=['GET'])
def allocationReview(org=None, account=None):
"""
Returns the Allocation Review page/form, which can only be accessed through
the Manage Departments page.
"""

# Retrieving the departments based on the org and account numbers
try:
dept = Department.get(Department.ORG == org, Department.ACCOUNT == account)
except (NameError, DoesNotExist):
abort(404)

# Checking admin rights
currentUser = require_login()
if not currentUser: # If the current user is not logged in
return render_template('errors/403.html')
if not currentUser.isLaborAdmin:
if currentUser.student:
return redirect('/laborHistory/' + currentUser.student.ID)
elif currentUser.supervisor:
return render_template('errors/403.html'), 403

# Retrieving the next year
# DON'T DELETE THE UNDERSCORES
_, _, nextAY = generateAdjacentYears()
# The generateAdjacentYears() function returns a tuple of three elements, and we only need the third value

return render_template('admin/allocationReview.html', department = dept, nextAY = nextAY)
102 changes: 0 additions & 102 deletions app/controllers/admin_routes/manage_departments.py

This file was deleted.

34 changes: 25 additions & 9 deletions app/controllers/admin_routes/termManagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,42 @@ def createTerms(termYear):
This function creates the terms for the given Academic Year
"""
code = termYear * 100
createdTerms = []
for i in range(8):
try:
if i == 0:
Term.create(termCode = code, termName = "AY {}-{}".format(termYear, termYear + 1), isAcademicYear=True)
term = Term.create(termCode = code, termName = "AY {}-{}".format(termYear, termYear + 1), isAcademicYear=True)
elif i == 1:
Term.create(termCode = (code + 11), termName = "Fall {}".format(termYear))
term = Term.create(termCode = (code + 11), termName = "Fall {}".format(termYear))
elif i == 7:
Term.create(termCode = (code + 4), termName = "Fall Break {}".format(termYear), isBreak=True)
term = Term.create(termCode = (code + 4), termName = "Fall Break {}".format(termYear), isBreak=True)
elif i == 2:
Term.create(termCode = (code + 1), termName = "Thanksgiving Break {}".format(termYear), isBreak=True)
term = Term.create(termCode = (code + 1), termName = "Thanksgiving Break {}".format(termYear), isBreak=True)
elif i == 3:
Term.create(termCode = (code + 2), termName = "Christmas Break {}".format( termYear), isBreak=True)
term = Term.create(termCode = (code + 2), termName = "Christmas Break {}".format( termYear), isBreak=True)
elif i == 4:
Term.create(termCode = (code + 12), termName = "Spring {}".format(termYear + 1))
term = Term.create(termCode = (code + 12), termName = "Spring {}".format(termYear + 1))
elif i == 5:
Term.create(termCode = (code + 3), termName = "Spring Break {}".format(termYear + 1), isBreak=True)
term = Term.create(termCode = (code + 3), termName = "Spring Break {}".format(termYear + 1), isBreak=True)
elif i == 6:
Term.create(termCode = (code + 13), termName = "Summer {}".format(termYear + 1), isBreak=True, isSummer=True)
term = Term.create(termCode = (code + 13), termName = "Summer {}".format(termYear + 1), isBreak=True, isSummer=True)
except IntegrityError as e:
pass
termCodeMap = {
0: code,
1: code + 11,
2: code + 1,
3: code + 2,
4: code + 12,
5: code + 3,
6: code + 13,
7: code + 4,
}
term = Term.get_or_none(Term.termCode == termCodeMap[i])

if term is not None:
createdTerms.append(term)

return createdTerms

@admin.route("/termManagement/setDate/", methods=['POST'])
def ourDate():
Expand Down
Loading