diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py
index 7106cb62..b4c34ea4 100755
--- a/app/controllers/main_routes/main_routes.py
+++ b/app/controllers/main_routes/main_routes.py
@@ -49,7 +49,7 @@ def supervisorPortal():
allSupervisors = Supervisor.select()
supervisorFirstName = fn.COALESCE(Supervisor.preferred_name, Supervisor.legal_name)
studentFirstName = fn.COALESCE(Student.preferred_name, Student.legal_name)
-
+ department = None
if currentUser.isLaborAdmin or currentUser.isFinancialAidAdmin or currentUser.isSaasAdmin:
departments = Department.select().order_by(Department.isActive.desc(), Department.DEPT_NAME.asc())
departments = [department for department in departments]
@@ -63,6 +63,8 @@ def supervisorPortal():
departments = [department for department in departments]
deptNames = [department.DEPT_NAME for department in departments]
+ supervisorPrimaryDepartment = Department.select().join(SupervisorDepartment) # count up all forms for a supervisor in department and get the max
+
supervisors = (Supervisor.select(Supervisor, supervisorFirstName)
.join_from(Supervisor, LaborStatusForm)
.join_from(LaborStatusForm, Department)
@@ -85,7 +87,7 @@ def supervisorPortal():
allSupervisors = allSupervisors,
students = students,
departments = departments,
- department = None,
+ department = department,
currentUser = currentUser
)
@@ -101,9 +103,9 @@ def getDatatableData(request):
sleJoin = False
currentUser = require_login()
- draw = int(request.form.get('draw', -1))
- rowNumber = int(request.form.get('start', -1))
- rowsPerPage = int(request.form.get('length', -1))
+ draw = int(request.form.get('draw', 0))
+ rowNumber = int(request.form.get('start', 0))
+ rowsPerPage = int(request.form.get('length', 25))
queryFilterData = request.form.get('data')
queryFilterDict = json.loads(queryFilterData)
sortBy = queryFilterDict.get('sortBy', "term")
@@ -167,6 +169,7 @@ def getDatatableData(request):
# this maps all of the values we expect to receive from the sorting dropdowns in the frontend
# to actual peewee objects we can sort by later
+ # the casing is weird because the columns that don't have any fields are are not capitalized
sortValueColumnMap = {
"term": Term.termCode,
"department": Department.DEPT_NAME,
@@ -174,8 +177,9 @@ def getDatatableData(request):
"supervisorLastName": Supervisor.LAST_NAME,
"studentFirstName": studentFirstNameCase,
"studentLastName": Student.LAST_NAME,
- "positionCode": LaborStatusForm.POSN_CODE,
"positionWLS": LaborStatusForm.WLS,
+ "positionTitle": LaborStatusForm.POSN_TITLE,
+ "positionType": LaborStatusForm.jobType,
"length": LaborStatusForm.startDate,
"createdBy": User.username,
"formStatus": FormHistory.status,
@@ -183,20 +187,35 @@ def getDatatableData(request):
}
if order == "DESC":
- filteredSearchResults = formSearchResults.order_by(sortValueColumnMap[sortBy].desc()).limit(rowsPerPage).offset(rowNumber)
+ filteredSearchResults = formSearchResults.order_by(fn.TRIM(sortValueColumnMap[sortBy]).desc()).limit(rowsPerPage).offset(rowNumber)
else:
- filteredSearchResults = formSearchResults.order_by(sortValueColumnMap[sortBy].asc()).limit(rowsPerPage).offset(rowNumber)
- formattedData = getFormattedData(filteredSearchResults)
+ filteredSearchResults = formSearchResults.order_by(fn.TRIM(sortValueColumnMap[sortBy]).asc()).limit(rowsPerPage).offset(rowNumber)
+ formattedData = getFormattedData(filteredSearchResults, queryFilterDict['view'])
formsDict = {"draw": draw, "recordsTotal": recordsTotal, "recordsFiltered": recordsTotal, "data": formattedData}
return jsonify(formsDict)
-def getFormattedData(filteredSearchResults):
+def getFormattedData(filteredSearchResults, view ='simple'):
'''
Putting the data in the correct format to be used by the JS file.
Because this implementation is using server-side processing of datatables,
the HTML for the datatables are also formatted here.
'''
+ if view == "simple":
+ formattedData = []
+ for form in filteredSearchResults:
+ # The order in which you append the items to 'record' matters and it should match the order of columns on the table!
+ formattedData.append([f"""
+
+
+ {form.formID.studentSupervisee.FIRST_NAME} {form.formID.studentSupervisee.LAST_NAME} ({form.formID.studentSupervisee.ID})
+
+
+ {form.status}
+
+ {form.formID.termCode.termName} - {form.formID.POSN_TITLE} ({form.formID.jobType}) - {form.formID.department.DEPT_NAME}
+ """])
+ return formattedData
supervisorHTML = '{} '
studentHTML = '