From 2587f4938f72fec47fbab788a55915f2a6ce0079 Mon Sep 17 00:00:00 2001 From: conwelld Date: Thu, 16 Jul 2026 15:26:41 -0400 Subject: [PATCH 1/7] solved issue service hours not being displayed in participation history --- app/controllers/main/routes.py | 2 ++ app/templates/main/userProfile.html | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/app/controllers/main/routes.py b/app/controllers/main/routes.py index 6f83f32dd..52cb7ca89 100644 --- a/app/controllers/main/routes.py +++ b/app/controllers/main/routes.py @@ -233,6 +233,7 @@ def viewUsersProfile(username): managersProgramDict = getManagerProgramDict(g.current_user) managersList = [id[1] for id in managersProgramDict.items()] totalSustainedEngagements = getEngagementTotal(getCommunityEngagementByTerm(volunteer)) + eventparticipant = list(EventParticipant.select(EventParticipant.hoursEarned).join(Event).where(EventParticipant.user == volunteer, EventParticipant.event == Event.id,).order_by(Event.id.asc())) return render_template ("/main/userProfile.html", username=username, @@ -252,6 +253,7 @@ def viewUsersProfile(username): managersList = managersList, participatedInLabor = getCeltsLaborHistory(volunteer), totalSustainedEngagements = totalSustainedEngagements, + eventparticipant = eventparticipant ) abort(403) diff --git a/app/templates/main/userProfile.html b/app/templates/main/userProfile.html index 13fafda69..dae71a97c 100644 --- a/app/templates/main/userProfile.html +++ b/app/templates/main/userProfile.html @@ -169,6 +169,7 @@

Event Name Participation Type Event Date + Service Hours {% for event in participatedEvents %} @@ -176,6 +177,11 @@

{{event.name}} {{event.participatedType}} {{event.startDate.strftime('%m/%d/%Y')}} + {% if event.participatedType == 'Volunteer' %} + {{eventparticipant[loop.index0].hoursEarned}} + {% else %} + - + {% endif %} {% endfor %} {% else %} From 2d0f90bfca68ad254e5a4b49829cc6f9176755c8 Mon Sep 17 00:00:00 2001 From: conwelld Date: Thu, 16 Jul 2026 16:34:33 -0400 Subject: [PATCH 2/7] fixed pr request changes --- app/controllers/main/routes.py | 7 +++++-- app/templates/main/userProfile.html | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/main/routes.py b/app/controllers/main/routes.py index 52cb7ca89..6fcaa6c68 100644 --- a/app/controllers/main/routes.py +++ b/app/controllers/main/routes.py @@ -233,7 +233,10 @@ def viewUsersProfile(username): managersProgramDict = getManagerProgramDict(g.current_user) managersList = [id[1] for id in managersProgramDict.items()] totalSustainedEngagements = getEngagementTotal(getCommunityEngagementByTerm(volunteer)) - eventparticipant = list(EventParticipant.select(EventParticipant.hoursEarned).join(Event).where(EventParticipant.user == volunteer, EventParticipant.event == Event.id,).order_by(Event.id.asc())) + eventParticipant = list(EventParticipant.select(EventParticipant.hoursEarned) + .join(Event) + .where(EventParticipant.user == volunteer, EventParticipant.event == Event.id,) + .order_by(Event.id.asc())) return render_template ("/main/userProfile.html", username=username, @@ -253,7 +256,7 @@ def viewUsersProfile(username): managersList = managersList, participatedInLabor = getCeltsLaborHistory(volunteer), totalSustainedEngagements = totalSustainedEngagements, - eventparticipant = eventparticipant + eventParticipant = eventParticipant ) abort(403) diff --git a/app/templates/main/userProfile.html b/app/templates/main/userProfile.html index dae71a97c..c73b00e22 100644 --- a/app/templates/main/userProfile.html +++ b/app/templates/main/userProfile.html @@ -178,7 +178,7 @@

{{event.participatedType}} {{event.startDate.strftime('%m/%d/%Y')}} {% if event.participatedType == 'Volunteer' %} - {{eventparticipant[loop.index0].hoursEarned}} + {{eventParticipant[loop.index0].hoursEarned}} {% else %} - {% endif %} From a08d6f38534fe92d8c7625adbe5753aeaee155a6 Mon Sep 17 00:00:00 2001 From: conwelld Date: Fri, 17 Jul 2026 11:13:49 -0400 Subject: [PATCH 3/7] fixed pr changes --- app/templates/main/userProfile.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/templates/main/userProfile.html b/app/templates/main/userProfile.html index c73b00e22..a8b3a76cb 100644 --- a/app/templates/main/userProfile.html +++ b/app/templates/main/userProfile.html @@ -168,20 +168,20 @@

Program Event Name Participation Type - Event Date Service Hours + Event Date {% for event in participatedEvents %} {{event.programName}} {{event.name}} {{event.participatedType}} - {{event.startDate.strftime('%m/%d/%Y')}} {% if event.participatedType == 'Volunteer' %} {{eventParticipant[loop.index0].hoursEarned}} {% else %} - - + N/A {% endif %} + {{event.startDate.strftime('%m/%d/%Y')}} {% endfor %} {% else %} From 53602a70ac855782ee010819c8a31aca0269293a Mon Sep 17 00:00:00 2001 From: Brian Ramsay Date: Wed, 9 Sep 2026 10:54:48 -0400 Subject: [PATCH 4/7] Show service hours only for isService events --- app/templates/main/userProfile.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/main/userProfile.html b/app/templates/main/userProfile.html index 9d23d3bb0..134081ac5 100644 --- a/app/templates/main/userProfile.html +++ b/app/templates/main/userProfile.html @@ -176,7 +176,7 @@

{{event.programName}} {{event.name}} {{event.participatedType}} - {% if event.participatedType == 'Volunteer' %} + {% if event.isService %} {{eventParticipant[loop.index0].hoursEarned}} {% else %} N/A From 8c66155d61a5897be06a2055aaa355a7b1902897 Mon Sep 17 00:00:00 2001 From: Brian Ramsay Date: Wed, 9 Sep 2026 11:31:07 -0400 Subject: [PATCH 5/7] Included hours earned in the output of participated events function --- app/logic/events.py | 24 +++++++++++++++++------- tests/code/test_events.py | 18 +++++++++++++++--- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/logic/events.py b/app/logic/events.py index 2577aa85a..dd1889705 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.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/tests/code/test_events.py b/tests/code/test_events.py index c2727d6dd..852e84b1f 100644 --- a/tests/code/test_events.py +++ b/tests/code/test_events.py @@ -959,6 +959,7 @@ def test_volunteerHistory(): startDate = "2021-12-12", isAllVolunteerTraining = False, program = participatedProgram) + # Create a non-program event in the past that the test user will have # participated in participatedEvent = Event.create(name = "Attended event", @@ -1024,7 +1025,7 @@ def test_calculateNewSeriesId(): assert calculateNewSeriesId() == maxSeriesId @pytest.mark.integration -def test_getParticipatedEventsForUser_participatedTypes(): +def test_getParticipatedEventsForUser_typesAndHours(): with mainDB.atomic() as transaction: user = User.create( username='usrtst2', @@ -1105,8 +1106,8 @@ def test_getParticipatedEventsForUser_participatedTypes(): EventParticipant.create(user=user, event=allVolunteerTrainingEvent) EventParticipant.create(user=user, event=laborEvent) - EventParticipant.create(user=user, event=volunteerEvent) - EventParticipant.create(user=user, event=laborVolunteerEvent) + EventParticipant.create(user=user, event=volunteerEvent, hoursEarned=5) + EventParticipant.create(user=user, event=laborVolunteerEvent, hoursEarned=3) result = getParticipatedEventsForUser(user) @@ -1114,10 +1115,21 @@ def test_getParticipatedEventsForUser_participatedTypes(): event.name: event.participatedType for event in result } + serviceHoursEarned = { + event.name: event.hoursEarned for event in result + } + assert participatedTypes["Labor shift"] == "Labor" + assert serviceHoursEarned["Labor shift"] == 0 + assert participatedTypes["Volunteer event"] == "Volunteer" + assert serviceHoursEarned["Volunteer event"] == 5 + assert participatedTypes["Labor volunteer event"] == "Labor & Volunteer" + assert serviceHoursEarned["Labor volunteer event"] == 3 + assert participatedTypes["All Volunteer Training"] == "Volunteer" + assert serviceHoursEarned["All Volunteer Training"] == 0 transaction.rollback() From 6bbefec10267f9f1bec7a7f20f1e09d9ca5f4df1 Mon Sep 17 00:00:00 2001 From: Brian Ramsay Date: Wed, 9 Sep 2026 11:34:46 -0400 Subject: [PATCH 6/7] Fix service hour display bug on profile --- app/logic/events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/logic/events.py b/app/logic/events.py index dd1889705..ae02cf477 100644 --- a/app/logic/events.py +++ b/app/logic/events.py @@ -436,7 +436,7 @@ def getParticipatedEventsForUser(user): .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, union.c.hoursEarned).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): From b9d9635d59de6a331fa43c0e7d9d1e2d5851cee2 Mon Sep 17 00:00:00 2001 From: Brian Ramsay Date: Wed, 9 Sep 2026 11:38:58 -0400 Subject: [PATCH 7/7] Remove unnecessary query --- app/controllers/main/routes.py | 6 ------ app/templates/main/userProfile.html | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/controllers/main/routes.py b/app/controllers/main/routes.py index 8c5222ea4..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,10 +233,6 @@ def viewUsersProfile(username): managersProgramDict = getManagerProgramDict(g.current_user) managersList = [id[1] for id in managersProgramDict.items()] totalSustainedEngagements = getEngagementTotal(getCommunityEngagementByTerm(volunteer)) - eventParticipant = list(EventParticipant.select(EventParticipant.hoursEarned) - .join(Event) - .where(EventParticipant.user == volunteer, EventParticipant.event == Event.id,) - .order_by(Event.id.asc())) handbookOverdue = getHandbookStatus(volunteer) training = hasGoneToTraining(g.current_user, g.current_term) @@ -260,7 +255,6 @@ def viewUsersProfile(username): managersList = managersList, participatedInLabor = getCeltsLaborHistory(volunteer), totalSustainedEngagements = totalSustainedEngagements, - eventParticipant = eventParticipant, handbookOverdue = handbookOverdue, training = training, ) diff --git a/app/templates/main/userProfile.html b/app/templates/main/userProfile.html index 2925a3608..be2ecc605 100644 --- a/app/templates/main/userProfile.html +++ b/app/templates/main/userProfile.html @@ -183,7 +183,7 @@

{{event.name}} {{event.participatedType}} {% if event.isService %} - {{eventParticipant[loop.index0].hoursEarned}} + {{event.hoursEarned}} {% else %} N/A {% endif %}