Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
218 commits
Select commit Hold shift + click to select a range
4a7be6c
edited supervisorDepartment
BetterRocket Jun 30, 2026
12d8d41
edited supervisorDepartment
BetterRocket Jun 30, 2026
a868455
added the position history file
brightfietsop-ux Jun 30, 2026
83c8c92
added the allocation model
johnlolonga19 Jun 30, 2026
caad7d3
Added dummy data: weren't able to check if they work though
nahom70 Jun 30, 2026
bea1a8c
changed migrate_db.sh data to add PositionHistory, and added dummy da…
conwelld Jun 30, 2026
2978b55
allocation table added
johnlolonga19 Jun 30, 2026
912f50f
dummy allocations added
BetterRocket Jun 30, 2026
a61ff1d
Successfully added dummy data for the SupervisorDepartment class
ArtemKurasov Jun 30, 2026
cebf62e
Inserted the demo data
BhushanSah Jul 1, 2026
539efde
added a second round of demo data to the allocation
fritzj2 Jul 1, 2026
6d58afd
We added more data for position history
Jul 1, 2026
e670c2f
fixed the demo_data to make it easier to merge, and fixed the positio…
conwelld Jul 1, 2026
4c3f875
fixed demo data to fit pre existing format
conwelld Jul 1, 2026
6666512
fixed formating
Jul 1, 2026
0d517a9
fixed formating again
Jul 1, 2026
e5869bb
fixed merge conflict
Jul 1, 2026
ad3c194
Merge branch 'PeeWeeAttribute_PosHis' into Nahom_Dee_Alpha_peeweeAttr…
munsakad Jul 1, 2026
c953725
Merge pull request #597 from BCStudentSoftwareDevTeam/Nahom_Dee_Alpha…
munsakad Jul 1, 2026
49b5eac
Modified allocation
BhushanSah Jul 1, 2026
ea12fae
Merge branch 'allocation_demoData_JJ' into PeeWeeAttribute-CG-BS
BhushanSah Jul 1, 2026
5545996
Merge pull request #600 from BCStudentSoftwareDevTeam/PeeWeeAttribute…
BhushanSah Jul 1, 2026
30c5fe9
fixed the format issue on demo data and made the composite key on pos…
conwelld Jul 1, 2026
364a5e3
Merge pull request #601 from BCStudentSoftwareDevTeam/allocation_demo…
BhushanSah Jul 1, 2026
9b7e778
changed meta class in position history adn fixed identifiers in demo …
conwelld Jul 1, 2026
5c027e3
Resolved the merge conflict with the demo data
ArtemKurasov Jul 1, 2026
a52eeca
Add base for department portal
BrianRamsay Jul 2, 2026
0ebcfd7
Fix menu item highlighting for dept portal
BrianRamsay Jul 2, 2026
ba5a40b
Add empty file for common routes
BrianRamsay Jul 2, 2026
65c6b03
added an HTML file for manage people added the main routes to the page
brightfietsop-ux Jul 2, 2026
7c1adec
Added member card
BhushanSah Jul 2, 2026
cc07c97
tried to add it
nahom70 Jul 2, 2026
6bb3e68
some change
conwelld Jul 2, 2026
c29f01f
added 3 sample buttons to learn HTML
johnlolonga19 Jul 2, 2026
f706242
Added the Manage Staff page
ArtemKurasov Jul 2, 2026
aa3a837
uniform sizing for cards that scale with the screen and no cards when…
fritzj2 Jul 3, 2026
d60b8e4
added an email symbol that opens in outlook
brightfietsop-ux Jul 3, 2026
645e85a
added a 10 position cap to the amount of visible positons
fritzj2 Jul 3, 2026
d3c0b04
removed an unecessary print statement from the main_routes.py
fritzj2 Jul 3, 2026
5c6f767
Merge remote-tracking branch 'origin/dp-position-card' into manage_po…
NYABUTOA Jul 3, 2026
09022bd
Updated the Manage Staff table
ArtemKurasov Jul 3, 2026
426e2e7
Added a hover indicator for names on the Manage Staff table
ArtemKurasov Jul 3, 2026
dfa5971
we added some things and the table we hard coded
NYABUTOA Jul 3, 2026
213848c
Merge branch 'card1-alloc' into dp-position-card
fritzj2 Jul 3, 2026
693191b
got the first card added from Dayton's branch
fritzj2 Jul 3, 2026
f00b0fa
merged members card and removed unused css from base
fritzj2 Jul 3, 2026
1bb8c18
added real people into the members card, its wrong and gives us everyone
fritzj2 Jul 3, 2026
570293c
Updated the members card
BhushanSah Jul 6, 2026
3f6aa59
changed the button from members to blue
fritzj2 Jul 6, 2026
77e9714
added the bottom border and centered the button
fritzj2 Jul 6, 2026
0346556
Merge remote-tracking branch 'origin/members-card' into Bright_Artem_…
ArtemKurasov Jul 6, 2026
abcd951
Add real data to the Current Allocation card
DanielRukwasha Jul 6, 2026
6c52ca9
fixedgit add app/controllers/main_routes/main_routes.py Now current d…
BhushanSah Jul 6, 2026
f26adc4
Merge branch 'dp-position-card' of https://github.com/BCStudentSoftwa…
BhushanSah Jul 6, 2026
cdabc2a
added changes to format with all 3 cards
conwelld Jul 6, 2026
ea79ff6
unordered list now bullets elements, icon is in the top right, and ro…
fritzj2 Jul 6, 2026
4cd48d8
Merge branch 'manage_positions_ADN' into dp-position-card
fritzj2 Jul 6, 2026
b75e822
Revert "Add real data to the Current Allocation card"
DanielRukwasha Jul 6, 2026
b1e8ee2
made changes so three cards show up
conwelld Jul 6, 2026
68c055b
Merge branch 'card1-alloc' of https://github.com/BCStudentSoftwareDev…
conwelld Jul 6, 2026
827becc
gitMerge branch 'dp-position-card' of https://github.com/BCStudentSof…
fritzj2 Jul 6, 2026
e975c48
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
fritzj2 Jul 6, 2026
c1ffd57
fixed supervisor for members card
BhushanSah Jul 6, 2026
3b800cf
merged new version of managepositions into our branch, fixed the main…
fritzj2 Jul 6, 2026
eb0b99f
Merge branch 'dp-position-card' of https://github.com/BCStudentSoftwa…
fritzj2 Jul 6, 2026
725ce6a
polished the UI
nahom70 Jul 6, 2026
5a585e3
Merge pull request #624 from BCStudentSoftwareDevTeam/dp-position-card
nahom70 Jul 6, 2026
be66a39
Turned the Manage Staff Table into a Data Table
ArtemKurasov Jul 6, 2026
f5b4976
began formatting allocation card for pull request draft
conwelld Jul 6, 2026
aa70ade
fixed the ban button length
brightfietsop-ux Jul 6, 2026
eacbf27
removed some hardcoded css, fixed the icon
fritzj2 Jul 6, 2026
c3b577a
merge commit with the allocation branch
fritzj2 Jul 6, 2026
dbb1bd1
Revert "merge commit with the allocation branch"
fritzj2 Jul 6, 2026
3bcc164
refixed the icon, added an if statement for the No positions edge case
fritzj2 Jul 6, 2026
f759f54
began fixing the position of the current alloc icon.
fritzj2 Jul 6, 2026
2e57799
added table borders
brightfietsop-ux Jul 6, 2026
c343599
Merge pull request #632 from BCStudentSoftwareDevTeam/PeeWeeAttribute
nahom70 Jul 6, 2026
c768d7b
added format changes to match the 3 cards and corrected color
conwelld Jul 6, 2026
0445144
Merge branch 'PeeWeeAttribute' into Bright_Artem_manage_people
ArtemKurasov Jul 6, 2026
0f137c0
merge commit with PeeWeeAttribute, creates a nested meta class
conwelld Jul 6, 2026
c304338
Merge branch 'PeeWeeAttribute' into allocation_card
conwelld Jul 6, 2026
05bd744
Merge pull request #596 from BCStudentSoftwareDevTeam/PeeWeeAttribute…
MImran2002 Jul 6, 2026
ae3189a
Dynamic data from Tracy
nahom70 Jul 6, 2026
2c720b0
Make the Manage Staff Table Pull From the Demo Data
ArtemKurasov Jul 7, 2026
62d5a13
added changes from demo
conwelld Jul 7, 2026
ae3f15e
Renamed Manage Staff to Manage Members + Changed Routes to the Manage…
ArtemKurasov Jul 7, 2026
ab3bfb9
Merge branch 'manage_positions_ADN' into PeeWeeAttribute
nahom70 Jul 7, 2026
ffe248f
Fix duplicate style attribute and stray backslash in departmentPortal…
DanielRukwasha Jul 7, 2026
fd01b32
attempting to get back end communication
conwelld Jul 7, 2026
b5fff5f
Merge branch 'PeeWeeAttribute' of https://github.com/BCStudentSoftwar…
conwelld Jul 7, 2026
0f435f2
Moved the isBanned attribute from SupervisorDepartment to Supervisor
ArtemKurasov Jul 7, 2026
fb12640
created a toggle button and took out a button
brightfietsop-ux Jul 7, 2026
63524f1
Fixed the switches + Moved all the styles to the managemembers.css file
ArtemKurasov Jul 7, 2026
e3572c5
made real data show up on card and changed demo data to work
conwelld Jul 7, 2026
d7f6ccf
resolved department portal merge conflict
conwelld Jul 7, 2026
1ea2a90
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
fritzj2 Jul 8, 2026
b1e9d1e
added changes from previous branch, card and main routes
fritzj2 Jul 8, 2026
7fda0cf
added space for the other cards, gave a db table for the positionHistory
fritzj2 Jul 8, 2026
d86c8ea
Fixed the url for the specific positions in the card
fritzj2 Jul 8, 2026
f6dabdf
rounded the corner of the card using base.css
fritzj2 Jul 8, 2026
45c156f
fixed allocation card to have all total data
conwelld Jul 8, 2026
a951515
view details -> view all positions
fritzj2 Jul 8, 2026
082569e
added the position history to the demo data to test the links
fritzj2 Jul 8, 2026
489c9c8
Made the Supervisees column on the Manage Members page reflect data f…
ArtemKurasov Jul 8, 2026
b35b407
saving changes for review
conwelld Jul 8, 2026
a106738
Fixed how Secondaries Are Displayed
ArtemKurasov Jul 8, 2026
e6a6e77
Moved all the styles to managemembers.css + Removed sorting from the …
ArtemKurasov Jul 8, 2026
410cf43
No passwords in files
BrianRamsay Jul 8, 2026
3cd1205
Added new model requiremetns
BrianRamsay Jul 8, 2026
a57e055
Add new DDL to prod backup
BrianRamsay Jul 8, 2026
a6e09db
Fix failing admin management tests
BrianRamsay Jul 8, 2026
2de8e2b
Fix failing tests - missing Term, and new tracy setup reqs
BrianRamsay Jul 8, 2026
4203dc5
Fixed remaining failing tests
BrianRamsay Jul 8, 2026
cfd9ee9
Merge pull request #640 from BCStudentSoftwareDevTeam/add-models
BrianRamsay Jul 8, 2026
97f05f5
Add option to run just one file
BrianRamsay Jul 8, 2026
10ae9a2
Merge branch 'department-portal-base' of github.com:BCStudentSoftware…
BrianRamsay Jul 8, 2026
31be945
added a flash message on status
brightfietsop-ux Jul 8, 2026
27e6019
trying to fix databse reset breaking data for card
conwelld Jul 8, 2026
cdd1016
merged changes from base
conwelld Jul 8, 2026
ce98927
Deleted the isActive attribute from SupervisorDepartment
ArtemKurasov Jul 8, 2026
9c710e6
Merge branch 'department-portal-base' of https://github.com/BCStudent…
fritzj2 Jul 8, 2026
d2c8e04
merged department-portal-base into position-card-604
fritzj2 Jul 8, 2026
2a36cb4
Merge branch 'department-portal-base' into position-card-604
fritzj2 Jul 8, 2026
0967002
merged peeweeattribute into Bright_Artem_manage_people
brightfietsop-ux Jul 8, 2026
306d26c
fixed the positionHistory in the demo_data.py
fritzj2 Jul 8, 2026
4849854
merged peeweeattribute into Bright_Artem_manage_people
brightfietsop-ux Jul 8, 2026
6f7791a
fixed demo data to work, card again has links
fritzj2 Jul 8, 2026
7b378f3
resolved merge conflict
brightfietsop-ux Jul 8, 2026
046f98a
reworded pos, pos_his, and pos_his_obj to be more clear/formatted cor…
fritzj2 Jul 8, 2026
77c80d6
figured out issue creaking card data, g.getopenterm is not holding th…
conwelld Jul 8, 2026
c701ac6
Removed the Tracy dependency from the position card, positionHistory …
fritzj2 Jul 8, 2026
2dfbeaf
Added flash messages for the Assign Coordinator switch and the Remove…
ArtemKurasov Jul 9, 2026
78df419
merging changes from brian branch
conwelld Jul 9, 2026
2a56e44
positions are pulled by status as well, demo data checks multiple dep…
fritzj2 Jul 9, 2026
27777bc
no more inline styling, created a css file for the styling changes
fritzj2 Jul 9, 2026
0660ff1
Made the Add Members search bar responsive
ArtemKurasov Jul 9, 2026
9c72af2
removed tracy from main_routes.py import, fixed if statement with a t…
fritzj2 Jul 9, 2026
539c46f
reverted an addition to base css. Now .card changes are in dp css file
fritzj2 Jul 9, 2026
be01507
removed redundant code in dp css
fritzj2 Jul 9, 2026
e2bbb61
Merge remote-tracking branch 'origin' into position-card-604
fritzj2 Jul 9, 2026
d68ed19
All bostrap icons uniform changes, fixed formating
fritzj2 Jul 9, 2026
a08e85e
fixed semantic bug in demo data, changed current_year to hardcoded data
conwelld Jul 9, 2026
9522be3
fixed semantic bug in demo data, changed current_year to hardcoded da…
conwelld Jul 9, 2026
c3abef5
removed all bootstrap icon styling since it messes with the sidebar
fritzj2 Jul 9, 2026
4577e31
i fixed the search button to only load supervisors
brightfietsop-ux Jul 9, 2026
3712fa0
the no positions for this department no longer has a link
fritzj2 Jul 9, 2026
a30bb1b
made changes still broken
conwelld Jul 9, 2026
3ad3cae
made changes still broken pt.2
conwelld Jul 9, 2026
653ae75
fixed merge issues
conwelld Jul 9, 2026
452ae62
added more positions to test 'and x more' positions
fritzj2 Jul 9, 2026
c22d121
made the cards stack on top of each other when the screen is too small
fritzj2 Jul 9, 2026
7772373
Changed the names of demo positions to be more realistic
fritzj2 Jul 9, 2026
bc05360
Began working on uniform sizing for the cards
fritzj2 Jul 9, 2026
38cb2c7
have real data on allocation card now, just need term code global var…
conwelld Jul 9, 2026
f890748
made the buttons autofill to the same height
fritzj2 Jul 10, 2026
7fe347b
need to fix g.openterm but data is good
conwelld Jul 10, 2026
8ad22e0
fixed merge issues
conwelld Jul 10, 2026
36ccceb
fixed the formating of the html and css
fritzj2 Jul 10, 2026
4327526
Added new demo data, removed dublicates in the Add Members search bar…
ArtemKurasov Jul 10, 2026
4a606a3
fixed formating of html for readability
fritzj2 Jul 10, 2026
64e49b8
fixed test error
conwelld Jul 10, 2026
0369e4a
Merge pull request #643 from BCStudentSoftwareDevTeam/demoDataFix_dpb
MImran2002 Jul 10, 2026
0e9b14a
filtered the tables not to show released students
brightfietsop-ux Jul 10, 2026
10f171e
changed the demo data to work better with the year changes
fritzj2 Jul 10, 2026
f1a5c83
Merge remote-tracking branch 'origin/department-portal-base' into pos…
fritzj2 Jul 10, 2026
9dc1d7a
Added a small shadow to the cards
fritzj2 Jul 10, 2026
d084729
made changes to card
conwelld Jul 10, 2026
7703be3
moved over only our changes from polluted branch
BetterRocket Jul 10, 2026
cd9985e
removed in-line CSS
BetterRocket Jul 10, 2026
948d267
removing unneeded change that snuck through
BetterRocket Jul 10, 2026
bd344da
fixed break hours
conwelld Jul 10, 2026
b089957
fixed the URL for parity
johnlolonga19 Jul 13, 2026
64d1630
Made Switches save the data to the database on the Manage Members page
ArtemKurasov Jul 13, 2026
5483e26
Fixed the size of icon
BhushanSah Jul 13, 2026
7180a27
Removed currentuser.login
BhushanSah Jul 13, 2026
17544d4
converted variables to camelCase
BetterRocket Jul 13, 2026
f9b5a86
merged upstream branch onto ours
BetterRocket Jul 13, 2026
f774151
removed vestigial code fragment
BetterRocket Jul 13, 2026
e845566
Made the switches work asynchronously
ArtemKurasov Jul 13, 2026
7d4e1d5
fixed all formatting ready for pr
conwelld Jul 13, 2026
ef1d4b0
fixed conditional indexing
johnlolonga19 Jul 13, 2026
9133d1c
fixed the phrasing of no active positions for dept. conditional for l…
fritzj2 Jul 13, 2026
3f443be
Merge pull request #639 from BCStudentSoftwareDevTeam/position-card-604
MImran2002 Jul 13, 2026
eaf5ebd
handled merge conflicts& integrated Members Card
BetterRocket Jul 13, 2026
b366a61
merged changes from position card
conwelld Jul 13, 2026
452eebf
remvoed print statement
conwelld Jul 13, 2026
c1f2c76
Fixed the Remove Button (partially) and the Ban button, but Broke the…
ArtemKurasov Jul 13, 2026
2eb46e3
Merged department-portal-base into Bright_Artem_manage_people
ArtemKurasov Jul 13, 2026
8252f0d
removed redundant code
conwelld Jul 13, 2026
2fbb322
collapsed supervisorDepartments definition
BetterRocket Jul 13, 2026
71d5fd7
fixed the for loop so it won't run more than 3 times
BhushanSah Jul 13, 2026
3482c4e
Merge branch 'MembersCard' of https://github.com/BCStudentSoftwareDev…
BhushanSah Jul 13, 2026
1f68174
Fixed the loop for postion card
BhushanSah Jul 13, 2026
60ada1e
Merge pull request #645 from BCStudentSoftwareDevTeam/MembersCard
MImran2002 Jul 13, 2026
79e47a6
fixed merge conflict member card
conwelld Jul 13, 2026
e373a5b
Tried Merging development-portal-base into Bright_Artem_manage_people…
ArtemKurasov Jul 13, 2026
4f3c76a
fixed the merge conflict
brightfietsop-ux Jul 14, 2026
d2d74f6
added a route to the manage supervisor button
brightfietsop-ux Jul 14, 2026
d03906c
fixed some pr problems
conwelld Jul 14, 2026
a663d78
added an import statement to fix add members
brightfietsop-ux Jul 14, 2026
135d43a
fixed a bug on add with b-number
brightfietsop-ux Jul 14, 2026
6b98e02
Merge pull request #642 from BCStudentSoftwareDevTeam/Bright_Artem_ma…
MImran2002 Jul 14, 2026
6eedbfa
fixed all merge conflicts
conwelld Jul 14, 2026
b0ba70d
fixed format in managemembers
conwelld Jul 14, 2026
7f8358c
Merge pull request #647 from BCStudentSoftwareDevTeam/allocation_card
MImran2002 Jul 14, 2026
9afb2c6
fixed issue for route and can merge successsfully
nahom70 Jul 15, 2026
7328dbc
Revert allocation card PR #647
MImran2002 Jul 20, 2026
9c716f5
Revert "Merge pull request #642 from BCStudentSoftwareDevTeam/Bright_…
MImran2002 Jul 20, 2026
78e8786
Revert "Merge pull request #645 from BCStudentSoftwareDevTeam/Members…
MImran2002 Jul 20, 2026
3e5a529
Revert position card PR #639
MImran2002 Jul 20, 2026
dad0a49
Reverted the merges
ArtemKurasov Jul 20, 2026
0684323
Got all of the changes from the Manage_Members_Bright_Artem branch
ArtemKurasov Jul 20, 2026
8bcd89b
made the portal to work
brightfietsop-ux Jul 20, 2026
24d7ca1
made the isBanned banner to display a popup
brightfietsop-ux Jul 20, 2026
194ff1c
Fixed the Assign Coordinator switch + moved some of the logic to mana…
ArtemKurasov Jul 21, 2026
52b7efc
Used functions from app/logic/manageMembers..py
ArtemKurasov Jul 21, 2026
c2052a7
removed a duplicate function
brightfietsop-ux Jul 21, 2026
a649439
broke down the mangeMembers into samller functions and moved it app/l…
brightfietsop-ux Jul 21, 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
3 changes: 0 additions & 3 deletions app/config/contributors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,4 @@ contributors:
- name: "Oluwagbayi Makinde"
username: "makindeo"
year: 2024
- name: "Bhushan Sah "
username: "sahb"
year: 2029

1 change: 1 addition & 0 deletions app/controllers/main_routes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def injectGlobalData():
'lastStaticUpdate': lastStaticUpdate}

from app.controllers.main_routes import main_routes
from app.controllers.main_routes import departmentPortal
from app.controllers.main_routes import laborStatusForm
from app.controllers.main_routes import laborHistory
from app.controllers.main_routes import alterLSF
Expand Down
172 changes: 172 additions & 0 deletions app/controllers/main_routes/departmentPortal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import re
from datetime import date
from flask import render_template, request, json, redirect, session, url_for, send_file, g, flash, jsonify
from peewee import JOIN, DoesNotExist, fn, Case
from functools import reduce
import operator
from app.logic.userInsertFunctions import createSupervisorFromTracy
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.laborReleaseForm import LaborReleaseForm
from app.models.term import Term
from app.controllers.admin_routes.allPendingForms import checkAdjustment
from app.controllers.main_routes import main_bp
from app.logic.download import CSVMaker, saveFormSearchResult, retrieveFormSearchResult
from app.logic.search import getDepartmentsForSupervisor, searchPerson, searchSupervisorPortal
from app.login_manager import require_login, logout
from app.logic.getTableData import getDatatableData
from app.logic.banner import Banner
from flask import abort
from app.logic.manageMembers import supervisorsDbToDict, currentAcademicYear
from app.logic.search import limitSearchByUserDepartment, studentDbToDict, usernameFromEmail
from app.logic.manageMembers import getCurrentDepartment,getDepartmentMembers,getReleasedFormIds,getStudentCounts,attachPositionCounts

@main_bp.route('/department/<org>/<account>/members', methods=['GET'])
def manageMembers(org=None, account=None):
"""Generates the Manage Members page."""
currentUser = require_login()
if not currentUser or not currentUser.supervisor:
if currentUser.student:
return redirect(url_for('main.laborhistory', id=currentUser.student.ID))
return render_template('errors/403.html'), 403

currentSupervisor = Supervisor.get(Supervisor.ID == currentUser.supervisor)
dept = getCurrentDepartment(org, account)

members = getDepartmentMembers(dept)
counts = getStudentCounts(dept)
members = attachPositionCounts(members, counts)

return render_template(
'main/manageMembers.html',
members=members,
department=dept,
currentSupervisor=currentSupervisor,
currentAcademicYear=currentAcademicYear()
)



@main_bp.route('/members/search/<query>', methods=['GET'])
def searchMember(query=None):
"""
Search student table and STUDATA for student results.
"""
currentUser = require_login()
accessAllowed = currentUser and (currentUser.supervisor or currentUser.isLaborAdmin)
if not accessAllowed:
return render_template('errors/403.html'), 403

recordedSupervisors = [] # supervisors recorded in the database
query = query.strip()

displayedSupervisors = Supervisor.select()

# bnumber search
if re.match(r'[Bb]\d+', query):
recordedSupervisors = list(map(supervisorsDbToDict, displayedSupervisors.where(Supervisor.ID % "{}%".format(query.upper()))))


# name search
else:
if " " not in query:
search = query.upper() + "%"
results = displayedSupervisors.where(Supervisor.preferred_name ** search | Supervisor.legal_name ** search | Supervisor.LAST_NAME ** search)
else:
search = query.upper().split()
firstQuery = search[0] + "%"
lastQuery = search[-1] + "%"
results = displayedSupervisors.where((Supervisor.preferred_name ** firstQuery | Supervisor.legal_name ** firstQuery) & Supervisor.LAST_NAME ** lastQuery)

recordedSupervisors = list(map(supervisorsDbToDict, results))


# combine lists, remove duplicates, and then sort
supervisors = list({v['bnumber']:v for v in (recordedSupervisors)}.values())
supervisors = sorted(supervisors, key=lambda f: f['firstName'] + f['lastName'])

return jsonify(supervisors)

@main_bp.route('/members/coordinator_switch', methods=['POST'])
def coordinatorSwitch():
"""
Assigns or unassignes a supervisor as a Labor Coordinator.
"""
data = request.get_json()
supervisorID = data.get("supervisorID")
isCoordinator = data.get("isCoordinator")

departmentID = session.get('current_department_id')
if not departmentID:
return "", 400

member = SupervisorDepartment.get(
(SupervisorDepartment.supervisor == supervisorID) &
(SupervisorDepartment.department == departmentID)
)
member.isCoordinator = isCoordinator
member.save()

return "", 200


@main_bp.route('/members/ban_switch', methods=['POST'])
def elegibilitySwitch():
"""
Updates a supervisor's eligibility status.
"""
data = request.get_json()
supervisorID = data.get("supervisorID")

member = Supervisor.get(Supervisor.ID == supervisorID)

member.isBanned = not member.isBanned
member.save()

return "", 200


@main_bp.route('/members/remove', methods=['DELETE'])
def removeMember():
"""
Removes a staff member from a department.
"""
data = request.get_json()
supervisorID = data.get("supervisorID")

member = SupervisorDepartment.get(
(SupervisorDepartment.supervisor == supervisorID) &
(SupervisorDepartment.department == session['current_department_id'])
)
member.delete_instance()

return "", 200



@main_bp.route('/members/add', methods=['GET', 'POST'])
def addUserToDept():
"""
Adds a user to a department.
"""
userDeptData = request.form
supervisorDeptRecord = SupervisorDepartment.get_or_none(supervisor = userDeptData['supervisorID'], department = userDeptData['departmentID'])
try:
if supervisorDeptRecord:
return "False"

else:
supervisorID = userDeptData['supervisorID']
if not Supervisor.get_or_none(Supervisor.ID == supervisorID):
createSupervisorFromTracy(bnumber=supervisorID)

SupervisorDepartment.create(supervisor=supervisorID, department=userDeptData['departmentID'])
return "True"

except Exception as e:
print(f'Could not add user to department: {e}')
return "", 500
63 changes: 48 additions & 15 deletions app/controllers/main_routes/main_routes.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,6 +16,10 @@
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
from app.logic.userInsertFunctions import createSupervisorFromTracy
from app.models.positionHistory import PositionHistory


@main_bp.route('/logout', methods=['GET'])
def triggerLogout():
Expand Down Expand Up @@ -47,21 +51,50 @@ def supervisorPortal():
currentUser = currentUser
)

@main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST'])
def addUserToDept():
userDeptData = request.form
supervisorDeptRecord = SupervisorDepartment.get_or_none(supervisor = userDeptData['supervisorID'], department = userDeptData['departmentID'])
@main_bp.route('/department', methods=['GET'])
@main_bp.route('/department/<org>', methods=['GET'])
@main_bp.route('/department/<org>/<account>', methods=['GET'])
def departmentPortal(org=None,account=None):
if org and account:
try:
dept = Department.get(Department.ORG == org, Department.ACCOUNT == account)
except (NameError, DoesNotExist):
dept = None
else:
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,
# supervisors = supervisor,
# laborCoordinators=laborCoordinators,
currentUser=g.currentUser,
# positions = positionsList,
# posUrl = posUrl
)

@main_bp.route('/department/<org>/<account>/positions', methods=['GET'])
def managePositions(org, account):
try:
if supervisorDeptRecord:
return "False"
dept = Department.get(Department.ORG == org, Department.ACCOUNT == account)
except DoesNotExist:
return render_template('errors/404.html'), 404

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
positions = Tracy().getPositionsFromDepartment(org, account)
print(positions)
return render_template('main/managepositions.html',
department = dept,
department_name = dept.DEPT_NAME,
positions = positions
)

@main_bp.route('/supervisorPortal/download', methods=['POST'])
def downloadSupervisorPortalResults():
Expand Down Expand Up @@ -113,4 +146,4 @@ def submitToBanner(formHistoryId):
if save_form_status:
return "Form successfully submitted to Banner.", 200
else:
return "Submitting to Banner failed.", 500
return "Submitting to Banner failed.", 500
Loading