Skip to content

Commit 2624bb3

Browse files
authored
Merge pull request #1802 from BCStudentSoftwareDevTeam/rosterTrainingsHF
Rosters' Program Specific column wrongly marks Attended
2 parents 0088e56 + 64b8183 commit 2624bb3

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎app/controllers/admin/routes.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def eventDisplay(eventId):
373373

374374
currentEventRsvpAmount = getEventRsvpCount(event.id)
375375

376-
userParticipatedTrainingEvents = getParticipationStatusForTrainings(eventData['program'], [g.current_user], g.current_term)
376+
userParticipatedTrainingEvents = getParticipationStatusForTrainings(eventData['program'], [g.current_user], g.current_term, includeFutureEvents = False)
377377

378378
return render_template("events/eventView.html",
379379
eventData=eventData,

‎app/logic/participants.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)