@@ -116,7 +116,7 @@ def getEventParticipants(event):
116116
117117 return [p for p in eventParticipants ]
118118
119- def getParticipationStatusForTrainings (program , userList , term , returnStr = True ):
119+ def getParticipationStatusForTrainings (program , userList , term , includeFutureEvents = True ):
120120 """
121121 This function returns a dictionary of all trainings for a program and
122122 whether the current user participated in them.
@@ -130,7 +130,10 @@ def getParticipationStatusForTrainings(program, userList, term, returnStr = True
130130 .join (EventRsvp , JOIN .LEFT_OUTER ).switch ()
131131 .join (Term )
132132 .where (isRelevantTraining , (Event .isCanceled != True )).order_by (Event .startDate ))
133-
133+ if not includeFutureEvents :
134+ programTrainings = programTrainings .where (
135+ (Event .startDate < datetime .now ().date ()) |
136+ ((Event .startDate == datetime .now ().date ()) & (Event .timeStart <= datetime .now ().time ())))
134137 # Create a dictionary where the keys are trainings and values are a set of those who attended
135138 trainingData = defaultdict (set )
136139 for training in programTrainings :
@@ -151,7 +154,7 @@ def getParticipationStatusForTrainings(program, userList, term, returnStr = True
151154 for user in userList :
152155 if training .name not in userParticipationStatus [user .username ] or user .username in attendeeList :
153156 userParticipationStatus [user .username ][training .name ] = [training , user .username in attendeeList ]
154- if returnStr :
157+ if includeFutureEvents :
155158 return {user .username : list (userParticipationStatus [user .username ].values ()) for user in userList }
156159 else :
157160 return {user : list (userParticipationStatus [user .username ].values ()) for user in userList }
@@ -178,7 +181,7 @@ def getTrainingsForInterestedParticipants(programID, interestedUsers):
178181
179182 Gracefully handles multiple trainings of the same type (e.g., two All Volunteers Trainings)
180183 """
181- trainedUsers = getParticipationStatusForTrainings (programID , interestedUsers , g .current_term , returnStr = False )
184+ trainedUsers = getParticipationStatusForTrainings (programID , interestedUsers , g .current_term , includeFutureEvents = False )
182185 now = datetime .now ()
183186 bannedUsers = list (User
184187 .select (User .username )
@@ -207,7 +210,7 @@ def getTrainingsForInterestedParticipants(programID, interestedUsers):
207210 for event in trainedUsers [interestedUser ]:
208211 if not event [1 ]: # they didn't attend this training
209212 continue
210- elif event [0 ].isAllVolunteerTraining : # They attended AVT
213+ elif event [0 ].isAllVolunteerTraining or event [ 0 ]. isCeltsTraining : # They attended AVT or ACT
211214 trainedAndInterested [interestedUser .username ]["allVolunteer" ] = True
212215 elif event [0 ].isTraining : # They attended the Program-specific training
213216 trainedAndInterested [interestedUser .username ]["programSpecific" ] = True
0 commit comments