Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
189 commits
Select commit Hold shift + click to select a range
3d5a7ac
Started moving files
Meatchema Jul 1, 2025
925b1a7
We have put the getuser function and the flashmessage into one file i…
Meatchema Jul 1, 2025
d47a205
Fixed some files and reorganized some. There is a circular import iss…
BesherKitaz Jul 2, 2025
09e1286
New file studentsFromTracy added to try to get rid of circular impor…
Meatchema Jul 3, 2025
61178e1
Fix circular import issue and created departmentPositions file.
BesherKitaz Jul 3, 2025
318ddfe
Moved allPending logic functions to allPending in logic.
BesherKitaz Jul 3, 2025
76b1fc1
Moved most logic functions form routes folders to logic. Resolved all…
BesherKitaz Jul 3, 2025
64c226e
Delete a lot of weird OneNote files and an empty downlaod file
Meatchema Jul 10, 2025
2cae239
removed all 'approved reluctantly' instances in the code
jjijon7000 Jul 18, 2025
e2993bc
fixed sql file
jjijon7000 Jul 18, 2025
7507a6e
Moved some functions based on the most recent feedback on PR
BesherKitaz Jul 30, 2025
653655d
Pulling down remote branch
BesherKitaz Jul 30, 2025
4e9239b
Solving merge
BesherKitaz Jul 30, 2025
49169ed
Changed as request in the PR
BesherKitaz Aug 1, 2025
b5786e8
merging
BesherKitaz Aug 1, 2025
01f3155
createOverloadForm didn't have the whole function moved
BrianRamsay Aug 15, 2025
3f1528d
Fix imports for tests
BrianRamsay Aug 15, 2025
b988262
Fix tests broken by new demo data
BrianRamsay Aug 15, 2025
9e86db0
Resolve merge conflicts from recent dev changes, tests passing again
BrianRamsay Aug 15, 2025
ce3b397
Refactor the approval modal data function a little because it hurt
BrianRamsay Aug 15, 2025
5d2fca2
Logout actually works! Required shibboleth2.xml change also
BrianRamsay Aug 18, 2025
be9d9b9
Fix missing import
BrianRamsay Aug 18, 2025
7444792
Add Form type to the downloads
BrianRamsay Aug 18, 2025
4eb3506
Resolve merge conflicts
BrianRamsay Aug 18, 2025
87211c2
Add a button to resubmit a form to Banner
BrianRamsay Aug 18, 2025
f5086f5
changed variable name to be more accurate
BrianRamsay Aug 18, 2025
4d9bfb2
Merge branch 'development' of github.com:BCStudentSoftwareDevTeam/lsf…
BrianRamsay Aug 18, 2025
1f6f7ee
Resolve conflict with backup
BrianRamsay Aug 19, 2025
aaaf460
Make contact person on release form nullable
BrianRamsay Aug 19, 2025
bf406ec
Add missing table to prod backup
BrianRamsay Aug 22, 2025
6484661
Implemented logic for default term to match to current real-life term
ojmakinde Aug 22, 2025
0341ddf
Adjusted + removed pointless tests
ojmakinde Aug 22, 2025
f3c64bf
Make sure the base data email template matches the one in production
BrianRamsay Aug 25, 2025
1b21d0d
Removed unused query
ojmakinde Aug 28, 2025
a3d3d1c
Removed another unused query
ojmakinde Aug 28, 2025
1034de3
Optimized the Term query to fetch Terms from Term table instead of La…
ojmakinde Aug 28, 2025
56ab3fa
More micro-optimizations
ojmakinde Aug 28, 2025
3a4f7e0
Realized that len() executes the query, but .count() returns the count.
ojmakinde Aug 29, 2025
4281986
Optimized departments query
ojmakinde Aug 29, 2025
4f195b1
Micro-optimizations that didn't reduce the number of queries
ojmakinde Aug 29, 2025
30b0252
Micro-optimizations that didn't reduce the number of queries
ojmakinde Aug 29, 2025
312609a
Merge branch 'optimize-supervisor-portal' of https://github.com/BCStu…
JohnCox2211 Sep 2, 2025
affceec
Added div label to find dropdowns, copied logic from adminmanagement …
JohnCox2211 Sep 3, 2025
c418861
labeled div for term drop search, copied logic
JohnCox2211 Sep 3, 2025
a986f85
added route for live search -> copied from
JohnCox2211 Sep 3, 2025
c06541a
Progress with live search for terms, getting
JohnCox2211 Sep 4, 2025
871ff03
Fixed the duplication
ojmakinde Sep 4, 2025
09ce887
merged functionality of multiple dictionaries
ojmakinde Sep 5, 2025
8fac2f4
Minor changes
ojmakinde Sep 5, 2025
71177a0
Extended search functionality to other fields in the Supervisor search
ojmakinde Sep 5, 2025
fd43754
Deleted old supervisor portal queries
ojmakinde Sep 5, 2025
3dd9653
Shortened the query
ojmakinde Sep 5, 2025
232b756
Implemented searching with multiple names
ojmakinde Sep 5, 2025
fbf8ca4
Fixed minor bug in queries
ojmakinde Sep 5, 2025
ba441f9
Only valid users can now see 'All Departments'
ojmakinde Sep 5, 2025
f1e2583
Fixed bug with the display of 'All Supervisors' option
ojmakinde Sep 5, 2025
063b0a3
Completely fixed the 'All' display for all cases. Only the debouncing…
ojmakinde Sep 5, 2025
308f003
cleaned up unused imports and debug comments
JohnCox2211 Sep 8, 2025
786cc8e
Fixed getDepartmentsForSupervisor function
JohnCox2211 Sep 8, 2025
13184a9
added autofill of the droplist back to departments
JohnCox2211 Sep 8, 2025
a7c3857
removed empty variables
JohnCox2211 Sep 8, 2025
d10ab68
working on the script
MImran2002 Sep 8, 2025
a838ce2
email handler done
MImran2002 Sep 8, 2025
47bfdbc
Minor fixes
ojmakinde Sep 10, 2025
8b689a4
Added placeholder to make dynamic search more intuitive
ojmakinde Sep 10, 2025
33ddf5e
Restructured parts of the logic
ojmakinde Sep 10, 2025
0964f53
converted js to jquery for consistency
JohnCox2211 Sep 10, 2025
7148b83
automation script done
MImran2002 Sep 10, 2025
b6dcc9a
Created PR template
ojmakinde Sep 11, 2025
de094c1
Added comments
ojmakinde Sep 11, 2025
e0252ed
Merge pull request #532 from BCStudentSoftwareDevTeam/create-pr-template
BrianRamsay Sep 11, 2025
4900b30
Split up the form in adminManagement.html into
JohnCox2211 Sep 11, 2025
5d36d74
- removed leading spaces in form IDs
JohnCox2211 Sep 11, 2025
4558544
Add 'Approve' button in labor history form labor modal
ali-ramazani Sep 12, 2025
ab8a14c
Resolve merge conflicts
BrianRamsay Sep 12, 2025
b3a911e
working but still email is not sending but the script pass
MImran2002 Sep 12, 2025
d9c4b72
optimzation for python adminManagement code,
JohnCox2211 Sep 15, 2025
78ccc2d
Adding templete, for email.
RueHaile Sep 19, 2025
ec51ee3
script is working but needs polished
MImran2002 Sep 19, 2025
4059b72
changes done
MImran2002 Sep 19, 2025
505b3af
Supervisor portal now displays overload status,
JohnCox2211 Sep 22, 2025
e11fe17
added release pending status for supervisor portal
JohnCox2211 Sep 23, 2025
0edf8d1
working script
MImran2002 Sep 23, 2025
0baf2c6
added display logic for overload/rlease to student
JohnCox2211 Sep 23, 2025
956be68
"just committing"
MImran2002 Sep 23, 2025
ddac79f
Display for overload/release seemingly works on
JohnCox2211 Sep 25, 2025
6e2883b
removed some prints
JohnCox2211 Sep 25, 2025
c8427d8
Fixed error uploaded from studentOverloadApp.py
JohnCox2211 Sep 29, 2025
80d57e9
updated algorithm for setting display_status in
JohnCox2211 Sep 29, 2025
3b50876
modified if/else chain in main_routes
JohnCox2211 Sep 29, 2025
2963af8
Merge branch 'organizingtest' of https://github.com/BCStudentSoftware…
JohnCox2211 Sep 29, 2025
78d0a3e
Merge branch 'organizingtest' of https://github.com/BCStudentSoftware…
JohnCox2211 Sep 29, 2025
2970ee1
working on the functions
MImran2002 Sep 29, 2025
4218e74
Merge pull request #525 from BCStudentSoftwareDevTeam/fix-default-term
Karina-Agliullova Sep 30, 2025
cef5ee6
Merge branch 'organizingtest' of https://github.com/BCStudentSoftware…
JohnCox2211 Sep 30, 2025
3d9eff4
You will no longer see a list of students after
JohnCox2211 Sep 30, 2025
67ee758
removed duplicate getUser function, also removed
JohnCox2211 Sep 30, 2025
16e4fc6
Merge branch 'organizingtest' of https://github.com/BCStudentSoftware…
JohnCox2211 Sep 30, 2025
0471787
Merge branch 'dynamic-search-supervisor-portal' of https://github.com…
JohnCox2211 Sep 30, 2025
3ea3879
added flash messag for approval of pending forms
JohnCox2211 Oct 8, 2025
10bf9b2
almost done the only thing needed is to remove print statements
MImran2002 Oct 10, 2025
7e80937
Merge branch 'organizingtest' of https://github.com/BCStudentSoftware…
MImran2002 Oct 10, 2025
3b849be
updating the funbciton and scripts
MImran2002 Oct 10, 2025
8772987
accidently removed base_data.py
MImran2002 Oct 10, 2025
6d40a8d
remove print statements and change the language of the email template
MImran2002 Oct 13, 2025
ad032a1
Discovered that the reason why the select options were not loading is…
ojmakinde Oct 14, 2025
f66ee91
Implemented a cleaner approach to cookie fetching and fixed a syntax …
ojmakinde Oct 15, 2025
bbc73e5
Moved searchSupervisorPortal function
ojmakinde Oct 15, 2025
addca1a
changed flash msg logic
JohnCox2211 Oct 15, 2025
ac3b94e
Merge branch 'organizingtest' of https://github.com/BCStudentSoftware…
JohnCox2211 Oct 15, 2025
a3378b3
modified logic to match new structure of
JohnCox2211 Oct 15, 2025
8cd7841
correct the replaced logic from my original pr
JohnCox2211 Oct 15, 2025
07261ec
resolved most of brian's comments,
JohnCox2211 Oct 15, 2025
eb1b5e6
changed variables to be all camel case
JohnCox2211 Oct 22, 2025
ff4f29d
Merge pull request #548 from BCStudentSoftwareDevTeam/production
BrianRamsay Oct 22, 2025
ea0a2b5
refactored code to remove loop in adminManagement
JohnCox2211 Oct 22, 2025
fa34c2e
all forms able to be submitted now with refactor
JohnCox2211 Oct 23, 2025
f4f5a37
Figured out fin aid admins weren't being added
JohnCox2211 Oct 23, 2025
448ed0f
removed print.........
JohnCox2211 Oct 23, 2025
ba66e8d
Fix display bug for position codes
BrianRamsay Oct 29, 2025
587aaa7
Make the application respect the use_banner config item if it exists
BrianRamsay Oct 29, 2025
3b746f7
Note a found bug
BrianRamsay Oct 29, 2025
f3a218a
Merge branch 'development' into organizingtest
BrianRamsay Oct 29, 2025
91a8c35
Merge pull request #494 from BCStudentSoftwareDevTeam/organizingtest
BrianRamsay Oct 29, 2025
7e7b765
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
JohnCox2211 Oct 29, 2025
7e60541
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
JohnCox2211 Oct 29, 2025
1a9f9f7
student statuses now show release and overload
JohnCox2211 Oct 29, 2025
6548fbe
Merge branch 'development' into approval-flash
BrianRamsay Oct 31, 2025
6c7bcdd
removed debug prints
JohnCox2211 Nov 3, 2025
8122b88
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
MImran2002 Nov 3, 2025
cfa014d
New fix for displaying different student statuses
JohnCox2211 Nov 4, 2025
c3bbf4d
added adjusted status display on portal page
JohnCox2211 Nov 4, 2025
790225c
added adjustment status to the student labor
JohnCox2211 Nov 4, 2025
59fa57a
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
JohnCox2211 Nov 4, 2025
7959693
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
JohnCox2211 Nov 4, 2025
943628b
Merge branch 'approval-flash' of https://github.com/BCStudentSoftware…
JohnCox2211 Nov 4, 2025
1cf39ab
comments resolved and adminnotified removed and integrated into labor…
MImran2002 Nov 4, 2025
dbaa51a
removed import traceback
MImran2002 Nov 4, 2025
7088497
remove print statement
MImran2002 Nov 4, 2025
a8a6485
removed flash message from js and put it in the
JohnCox2211 Nov 4, 2025
db2a126
removed debug comments/code
JohnCox2211 Nov 4, 2025
50278f8
removed try and catch in finalApproval in favor
JohnCox2211 Nov 5, 2025
cc403f5
worked on chnages in pw, template and removing the template from sql,…
MImran2002 Nov 6, 2025
a1116c8
Expired now showed up
MImran2002 Nov 6, 2025
acb3d01
Merge pull request #542 from BCStudentSoftwareDevTeam/labor-history-s…
BrianRamsay Nov 7, 2025
a84bf2a
Merge branch 'development' into administrator-remove-fix
esw0624 Nov 7, 2025
1e7ffbd
Added implimentation of Button State
Meatchema Nov 10, 2025
b903caf
Merge branch 'development' into add-approve-button-in-labor-history-form
Meatchema Nov 10, 2025
5ba1e21
Merge branch 'development' into laborReleaseFormAdmin
esw0624 Nov 10, 2025
35656b0
remove space
MImran2002 Nov 10, 2025
c99c000
remove space
MImran2002 Nov 10, 2025
85ff5f2
Merge branch 'laborReleaseFormAdmin' of https://github.com/BCStudentS…
MImran2002 Nov 10, 2025
ba0e74c
added fade to the flask message.
RueHaile Nov 10, 2025
6c35dd6
Merge branch 'development' of github.com:BCStudentSoftwareDevTeam/lsf…
ojmakinde Nov 11, 2025
83a4184
Merge branch 'dynamic-search-supervisor-portal' of github.com:BCStude…
ojmakinde Nov 11, 2025
47a8136
Reduce individual queries on page load
BrianRamsay Nov 11, 2025
4b3dc8e
Merge pull request #540 from BCStudentSoftwareDevTeam/administrator-r…
BrianRamsay Nov 11, 2025
fd735c0
Merge branch 'development' into approval-flash
BrianRamsay Nov 11, 2025
d5dd4d1
Merge pull request #544 from BCStudentSoftwareDevTeam/approval-flash
BrianRamsay Nov 11, 2025
e7bbfc9
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
JohnCox2211 Nov 11, 2025
00b69f4
Merge branch 'development' into add-approve-button-in-labor-history-form
Meatchema Nov 11, 2025
1af7043
Fixed the bug with field presets not showing up for current supervise…
ojmakinde Nov 12, 2025
273696a
Removed debug statements
ojmakinde Nov 12, 2025
a37c214
Merge branch 'dynamic-search-supervisor-portal' of https://github.com…
JohnCox2211 Nov 12, 2025
3c3c2f0
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
MImran2002 Nov 14, 2025
2ab9972
Committing
MImran2002 Nov 14, 2025
0f67cd8
Merge
MImran2002 Nov 14, 2025
8fd5c6f
integrated form expiration script and labor admin notify
MImran2002 Nov 14, 2025
55d8ae7
reason for release and dtae fix, doesn't work yet- in progress
RueHaile Nov 17, 2025
4e465a2
Merge branch 'laborReleaseFormAdmin' of https://github.com/BCStudentS…
RueHaile Nov 17, 2025
d398e41
Removed the notion of 'currentTerm' (which we don't use) and correctl…
ojmakinde Nov 18, 2025
8ba87d2
Fixed the 'all active terms' query error from incorrect use of datetime
ojmakinde Nov 19, 2025
a74aca5
Merge pull request #529 from BCStudentSoftwareDevTeam/dynamic-search-…
BrianRamsay Nov 19, 2025
145aefc
the username and reasons have now showed correctly in the labor relea…
MImran2002 Nov 20, 2025
9942cea
Merge branch 'laborReleaseFormAdmin' of https://github.com/BCStudentS…
MImran2002 Nov 20, 2025
e3bf9b2
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
MImran2002 Nov 20, 2025
b5860e4
Adding template change
RueHaile Nov 20, 2025
84a0003
getting rid of debug prints
RueHaile Nov 21, 2025
50d1ac5
Merge branch 'development' into add-approve-button-in-labor-history-form
Meatchema Nov 24, 2025
5d6ba08
Change button text
BrianRamsay Nov 24, 2025
fc323c4
Removed duplicated Email Labor button
BrianRamsay Nov 24, 2025
f4f33b8
Merge pull request #538 from BCStudentSoftwareDevTeam/add-approve-but…
BrianRamsay Nov 24, 2025
8d82bb5
Merge branch 'development' into laborReleaseFormAdmin
BrianRamsay Nov 25, 2025
37904bc
Better name for emailhandler method
BrianRamsay Nov 25, 2025
f972467
Eliminate unneeded variable with bad name
BrianRamsay Nov 25, 2025
a3bda4c
Fix bad variable name
BrianRamsay Nov 25, 2025
ebf6825
Add basic output to script
BrianRamsay Nov 25, 2025
ff2bd20
Re-add PR template
BrianRamsay Nov 25, 2025
4986885
Merge pull request #546 from BCStudentSoftwareDevTeam/laborReleaseFor…
BrianRamsay Nov 25, 2025
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
14 changes: 14 additions & 0 deletions .github/workflows/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Issue Description

Fixes #<!-- add issue number -->
<!-- - Add issue description -->

## Changes

<!-- - Use bullet points to provide a description of added changes. -->
<!-- - Add images, where possible, to provide more context to your changes. -->

## Testing

<!-- - Use `backticks` to highlight shell commands or file directories in your test descriptions. -->
<!-- - Use bullet points to provide a concise description of testing procedure. -->
3 changes: 2 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

app.config['use_shibboleth'] = (app.config['ENV'] == 'production')
app.config['use_tracy'] = (app.config['ENV'] in ('production','staging'))
app.config['use_banner'] = (app.config['ENV'] in ('production','staging'))
if 'use_banner' not in app.config.keys():
app.config['use_banner'] = (app.config['ENV'] in ('production','staging'))

# Record and output queries if requested
from flask import session
Expand Down
137 changes: 35 additions & 102 deletions app/controllers/admin_routes/adminManagement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from app.controllers.admin_routes import *
from app.models.user import User, DoesNotExist
from app.models.user import *
from app.controllers.admin_routes import admin
from flask import request
Expand All @@ -8,7 +7,10 @@
from app.models.supervisor import Supervisor
from app.models.student import Student
from app.logic.tracy import Tracy
from app.logic.userInsertFunctions import createUser, createSupervisorFromTracy, createStudentFromTracy
from app.logic.userInsertFunctions import createStudentFromTracy, createSupervisorFromTracy, createUser
from app.logic.adminManagement import searchForAdmin, getUser
from app.logic.utils import adminFlashMessage


@admin.route('/admin/adminManagement', methods=['GET'])
# @login_required
Expand All @@ -23,7 +25,9 @@ def admin_Management():
elif currentUser.supervisor:
return render_template('errors/403.html'), 403

users = User.select()
users = (User.select(User,Supervisor,Student)
.join(Supervisor,join_type=JOIN.LEFT_OUTER).switch()
.join(Student,join_type=JOIN.LEFT_OUTER))
return render_template( 'admin/adminManagement.html',
title=('Admin Management'),
users = users
Expand All @@ -37,117 +41,46 @@ def adminSearch():
"""
try:
rsp = eval(request.data.decode("utf-8"))
userInput = rsp[1]
adminType = rsp[0]
userList = []
if adminType == "addlaborAdmin":
tracyStudents = Tracy().getStudentsFromUserInput(userInput)
students = []
for student in tracyStudents:
try:
existingUser = User.get(User.student == student.ID)
if existingUser.isLaborAdmin:
pass
else:
students.append(student)
except DoesNotExist as e:
students.append(student)
for student in students:
username = student.STU_EMAIL.split('@', 1)
userList.append({'username': username[0],
'firstName': student.FIRST_NAME,
'lastName': student.LAST_NAME,
'type': 'Student'
})
tracySupervisors = Tracy().getSupervisorsFromUserInput(userInput)
supervisors = []
for supervisor in tracySupervisors:
try:
existingUser = User.get(User.supervisor == supervisor.ID)
if ((existingUser.isLaborAdmin and adminType == "addlaborAdmin")
or (existingUser.isSaasAdmin and adminType == "addSaasAdmin")
or (existingUser.isFinancialAidAdmin and adminType == "addFinAidAdmin")):
pass
else:
supervisors.append(supervisor)
except DoesNotExist as e:
supervisors.append(supervisor)
for sup in supervisors:
username = sup.EMAIL.split('@', 1)
userList.append({'username': username[0],
'firstName': sup.FIRST_NAME,
'lastName': sup.LAST_NAME,
'type': 'Supervisor'})
userList = searchForAdmin(rsp)
return jsonify(userList)
except Exception as e:
print('ERROR Loading Non Labor Admins:', e, type(e))
return jsonify(userList)

@admin.route("/adminManagement/userInsert", methods=['POST'])
def manageLaborAdmin():
if request.form.get("addAdmin"):
newAdmin = getUser('addAdmin')
addAdmin(newAdmin, 'labor')
flashMessage(newAdmin, 'added', 'Labor')

elif request.form.get("removeAdmin"):
oldAdmin = getUser('removeAdmin')
removeAdmin(oldAdmin, 'labor')
flashMessage(oldAdmin, 'removed', 'Labor')

elif request.form.get("addFinancialAidAdmin"):
newAdmin = getUser('addFinancialAidAdmin')
addAdmin(newAdmin, 'finAid')
flashMessage(newAdmin, 'added', 'Financial Aid')

elif request.form.get("removeFinancialAidAdmin"):
oldAdmin = getUser('removeFinancialAidAdmin')
removeAdmin(oldAdmin, 'finAid')
flashMessage(oldAdmin, 'removed', 'Financial Aid')
actionMap = {
"addLaborAdmin": {"selectPickerID": "addAdmin", "type": "Labor", "action": "add", "pretty": "Labor"},
"removeLaborAdmin": {"selectPickerID": "removeAdmin", "type": "Labor", "action": "remove", "pretty": "Labor"},
"addFinAidAdmin": {"selectPickerID": "addFinancialAidAdmin", "type": "FinancialAid", "action": "add", "pretty": "Financial Aid"},
"removeFinAidAdmin": {"selectPickerID": "removeFinancialAidAdmin", "type": "FinancialAid", "action": "remove", "pretty": "Financial Aid"},
"addSaasAdmin": {"selectPickerID": "addSAASAdmin", "type": "Saas", "action": "add", "pretty": "SAAS"},
"removeSaasAdmin": {"selectPickerID": "removeSAASAdmin", "type": "Saas", "action": "remove", "pretty": "SAAS"},
}

elif request.form.get("addSAASAdmin"):
newAdmin = getUser('addSAASAdmin')
addAdmin(newAdmin, 'saas')
flashMessage(newAdmin, 'added', 'SAAS')

elif request.form.get("removeSAASAdmin"):
oldAdmin = getUser('removeSAASAdmin')
removeAdmin(oldAdmin, 'saas')
flashMessage(oldAdmin, 'removed', 'SAAS')
key = request.form.get('action')
meta = actionMap[key]
user = getUser(actionMap[key]['selectPickerID'])

# pick addAdmin or removeAdmin dynamically
if meta['action'] == 'add':
addAdmin(user, meta['type'])
else:
removeAdmin(user, meta['type'])

flashMessage(user,
'added' if meta["action"] == "add" else 'removed',
meta["pretty"])

return redirect(url_for('admin.admin_Management'))

def getUser(selectpickerID):
username = request.form.get(selectpickerID)
try:
user = User.get(User.username == username)
except DoesNotExist as e:
usertype = Tracy().checkStudentOrSupervisor(username)
supervisor = student = None
if usertype == "Student":
student = createStudentFromTracy(username)
else:
supervisor = createSupervisorFromTracy(username)
user = createUser(username, student=student, supervisor=supervisor)
return user

def addAdmin(newAdmin, adminType):
if adminType == 'labor':
newAdmin.isLaborAdmin = True
if adminType == 'finAid':
newAdmin.isFinancialAidAdmin = True
if adminType == 'saas':
newAdmin.isSaasAdmin = True
newAdmin.save()
def addAdmin(user, adminType):
setattr(user, f"is{adminType}Admin", True)
user.save()

def removeAdmin(oldAdmin, adminType):
if adminType == 'labor':
oldAdmin.isLaborAdmin = False
if adminType == 'finAid':
oldAdmin.isFinancialAidAdmin = False
if adminType == 'saas':
oldAdmin.isSaasAdmin = False
oldAdmin.save()
def removeAdmin(user, adminType):
setattr(user, f"is{adminType}Admin", False)
user.save()

def flashMessage(user, action, adminType):
message = "{} has been {} as a {} Admin".format(user.fullName, action, adminType)
Expand Down
Loading