diff --git a/app/controllers/main/routes.py b/app/controllers/main/routes.py index 6e109f7d4..6c570873e 100644 --- a/app/controllers/main/routes.py +++ b/app/controllers/main/routes.py @@ -24,7 +24,6 @@ from app.models.programManager import ProgramManager from app.models.backgroundCheck import BackgroundCheck from app.models.emergencyContact import EmergencyContact -from app.models.eventParticipant import EventParticipant from app.models.courseInstructor import CourseInstructor from app.models.backgroundCheckType import BackgroundCheckType @@ -234,8 +233,8 @@ def viewUsersProfile(username): managersProgramDict = getManagerProgramDict(g.current_user) managersList = [id[1] for id in managersProgramDict.items()] totalSustainedEngagements = getEngagementTotal(getCommunityEngagementByTerm(volunteer)) - handbookOverdue = getHandbookStatus(volunteer) + handbookOverdue = getHandbookStatus(volunteer) training = hasGoneToTraining(g.current_user, g.current_term) return render_template ("/main/userProfile.html", diff --git a/app/logic/events.py b/app/logic/events.py index 2577aa85a..ae02cf477 100644 --- a/app/logic/events.py +++ b/app/logic/events.py @@ -411,22 +411,32 @@ def getParticipatedEventsForUser(user): :return: A list of Event objects """ - # Does this handle labor only and/or includes labor events? - participatedEvents = (Event.select(Event, Program.programName, Case(None, ( - ((Event.allowsLabor | Event.name.contains("Labor")) & Event.isService, "Labor & Volunteer"), - ((Event.allowsLabor | Event.isLaborOnly | Event.name.contains("Labor")), "Labor"), - (Event.isService, "Volunteer")), "Attendee").alias("participatedType")) + eventName = fn.LOWER(Event.name) + checkIfLaborMeeting = eventName.contains("labor meeting") + + participatedEvents = (Event.select(Event, + Program.programName, + Case(None, + ( + ((Event.allowsLabor | Event.name.contains("Labor")) & Event.isService, "Labor & Volunteer"), + ((Event.allowsLabor | Event.isLaborOnly | Event.name.contains("Labor")), "Labor"), + (Event.isService, "Volunteer") + ), + "Attendee").alias("participatedType"), + EventParticipant.hoursEarned + ) .join(Program, JOIN.LEFT_OUTER).switch() .join(EventParticipant) .where(EventParticipant.user == user, Event.isAllVolunteerTraining == False, Event.deletionDate == None, Event.isCeltsTraining == False) .order_by(Event.startDate, Event.name)) - allVolunteer = (Event.select(Event, "", Value("Volunteer").alias("participatedType")) + + allVolunteer = (Event.select(Event, "", Value("Volunteer").alias("participatedType"), Value(0).alias("hoursEarned")) .join(EventParticipant) .where(Event.isAllVolunteerTraining == True, EventParticipant.user == user)) union = participatedEvents.union_all(allVolunteer) - unionParticipationWithVolunteer = list(union.select_from(union.c.id, union.c.programName, union.c.startDate, union.c.name, union.c.participatedType).order_by(union.c.startDate, union.c.name).execute()) + unionParticipationWithVolunteer = list(union.select_from(union.c.id, union.c.isService, union.c.programName, union.c.startDate, union.c.name, union.c.participatedType, union.c.hoursEarned).order_by(union.c.startDate, union.c.name).execute()) return unionParticipationWithVolunteer def validateNewEventData(data): diff --git a/app/templates/main/userProfile.html b/app/templates/main/userProfile.html index 156b037a3..be2ecc605 100644 --- a/app/templates/main/userProfile.html +++ b/app/templates/main/userProfile.html @@ -174,6 +174,7 @@