Coverage for app/logic/graduationManagement.py: 100%
18 statements
« prev ^ index » next coverage.py v7.2.7, created at 2025-07-22 20:03 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2025-07-22 20:03 +0000
1import xlsxwriter
2from app import app
3from peewee import JOIN
5from app.models.user import User
6from app.models.bonnerCohort import BonnerCohort
7from app.logic.minor import getMinorProgress
9def getGraduationManagementUsers():
10 """
11 Function to fetch all senior students along with their CCE Minor Progress and Bonner Status
12 """
14 eligibleUsers = (User.select(User.username, User.hasGraduated, User.rawClassLevel, User.firstName, User.lastName, BonnerCohort.year)
15 .join(BonnerCohort, JOIN.LEFT_OUTER, on=(BonnerCohort.user == User.username))
16 .where((User.rawClassLevel == 'Senior') | (User.rawClassLevel == "Graduating") | (User.hasGraduated == True)))
18 cceStudents = set([user["username"] for user in getMinorProgress()])
20 graduationManagementUsers = []
21 for user in eligibleUsers:
22 userDict = user.__dict__
23 graduationManagementUsers.append({
24 "user": user,
25 "cohort": userDict['bonnercohort'].year if 'bonnercohort' in userDict else None,
26 "minorProgress": user.username in cceStudents})
28 return graduationManagementUsers
31def setGraduatedStatus(username, status):
32 """
33 Update a students graduation status based on the parameter status.
34 """
35 gradStudent = User.get(User.username == username)
37 # it is necessary we cast this to an int instead of a bool because the
38 # status is passed as a string and if we cast it to a bool it will always be True
39 gradStudent.hasGraduated = int(status)
41 gradStudent.save()