Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
020502b
removed repeated imports and unnecessary functions in the manage labo…
adjagbodjouf Jul 11, 2025
85bf773
combined volunteers and labor tables, added two new fields to partici…
adjagbodjouf Jul 11, 2025
81a6b93
made slight edits to routes and test data files
adjagbodjouf Jul 15, 2025
8b4e541
tables now show accurate information for each event
adjagbodjouf Jul 16, 2025
f7a0d3d
put volunteers.py, manageLabor.py and participants.py in the same fil…
adjagbodjouf Jul 16, 2025
f13e8a8
moved checkUserParticipant() to the mutual sectioin in participants.py
adjagbodjouf Jul 16, 2025
2cd0b2a
combined getStudentLabor and getEventVolunteers to getEventParticipants
adjagbodjouf Jul 16, 2025
ff23065
added file called sharedLogic
adjagbodjouf Jul 17, 2025
388e37e
removed eventLabor import
adjagbodjouf Jul 17, 2025
2535bd2
Combined the functions together
Shenderaz Jul 18, 2025
e97fcc2
finished combining all of the volunteers and labor functions
adjagbodjouf Jul 18, 2025
cac2ad5
fixed updateEventVolunteers
adjagbodjouf Jul 22, 2025
f89f8a4
cleaned up random spaces
adjagbodjouf Jul 22, 2025
a0d75aa
manage labor tab was missing due to pull from development
adjagbodjouf Jul 31, 2025
4f569b0
Merge branch 'development' of https://github.com/BCStudentSoftwareDev…
adjagbodjouf Jul 31, 2025
c818351
fixed more problems caused by pulling development
adjagbodjouf Aug 1, 2025
b340872
cleaned up random spaces
adjagbodjouf Aug 1, 2025
ad576af
Merge branch 'development' into labor-tab
bakobagassas Sep 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions app/controllers/admin/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@
from app.logic.fileHandler import FileHandler
from app.logic.bonner import getBonnerCohorts, makeBonnerXls, rsvpForBonnerCohort, addBonnerCohortToRsvpLog
from app.logic.serviceLearningCourses import parseUploadedFile, saveCourseParticipantsToDatabase, unapprovedCourses, approvedCourses, getImportedCourses, getInstructorCourses, editImportedCourses
from app.logic.participants import sortParticipants

from app.controllers.admin import admin_bp
from app.logic.volunteerSpreadsheet import createSpreadsheet
from app.logic.users import isBannedFromEvent

from peewee import DoesNotExist, JOIN
from app.logic.participants import updateEventLabor, getEventParticipants, addParticipantToEvent
from app.logic.sharedLogic import getEventLengthInHours
from app.logic.events import getPreviousSeriesEventData, getEventRsvpCount
from app.logic.users import getBannedUsers

@admin_bp.route('/admin/reports')
def reports():
Expand Down Expand Up @@ -687,3 +694,113 @@ def displayEventFile():
isChecked = fileData.get('checked') == 'true'
eventfile.changeDisplay(fileData['id'], isChecked)
return ""



@admin_bp.route('/event/<eventID>/manage_labor', methods=['GET', 'POST'])
def manageLaborPage(eventID):
try:
event = Event.get_by_id(eventID)
except DoesNotExist as e:
print(f"No event found for {eventID}", e)
abort(404)

if request.method == "POST":
laborUpdated = updateEventLabor(request.form)

# error handling depending on the boolean returned from updateEventLabor
if laborUpdated:
flash("Labor table succesfully updated", "success")
else:
flash("Error adding labor", "danger")
return redirect(url_for("admin.manageLaborPage", eventID=eventID))

# ------------ GET request ------------
elif request.method == "GET":
if not (g.current_user.isCeltsAdmin or (g.current_user.isCeltsStudentStaff and g.current_user.isProgramManagerForEvent(event))):
abort(403)

# ------- Grab the different lists of participants -------

bannedUsersForProgram = [bannedUser.user for bannedUser in getBannedUsers(event.program)]

eventLaborData, eventLabor = sortParticipants(event, True)

allRelevantUsers = list(set(participant.user for participant in (eventLabor + eventLaborData)))
# ----------- Get miscellaneous data -----------
eventLengthInHours = getEventLengthInHours(event.timeStart, event.timeEnd, event.startDate)
repeatingLabors = getPreviousSeriesEventData(event.seriesId)

return render_template("/events/manageLabor.html",
eventLaborData = eventLaborData,
eventLabor = eventLabor,
eventLength = eventLengthInHours,
event = event,
repeatingLabors = repeatingLabors,
bannedUsersForProgram = bannedUsersForProgram,)


@admin_bp.route('/removeLaborFromEvent', methods = ['POST'])
def removeLaborFromEvent():
user = request.form.get('username')
eventID = request.form.get('eventId')
if g.current_user.isAdmin:
(EventParticipant.delete().where(EventParticipant.user==user, EventParticipant.event==eventID)).execute()
flash("Student successfully removed", "success")
return ""

@admin_bp.route('/addLaborToEvent/<eventId>', methods = ['POST'])
def addLaborToEvent(eventId):
event = Event.get_by_id(eventId)
successfullyAddedLabor = False
usernameList = request.form.getlist("selectedLabor[]")
alreadyAddedList = []
addedSuccessfullyList = []
errorList = []

for user in usernameList:
userObj = User.get_by_id(user)
successfullyAddedLabor = addParticipantToEvent(userObj, event, True)
if successfullyAddedLabor == "already in":
alreadyAddedList.append(userObj.fullName)
else:
if successfullyAddedLabor:
addedSuccessfullyList.append(userObj.fullName)
else:
errorList.append(userObj.fullName)


studentLabor = ""
if alreadyAddedList:
studentLabor = ", ".join(vol for vol in alreadyAddedList)
flash(f"{studentLabor} was already added to this event.", "warning")

if addedSuccessfullyList:
studentLabor = ", ".join(vol for vol in addedSuccessfullyList)
flash(f"{studentLabor} added successfully.", "success")

if errorList:
studentLabor = ", ".join(vol for vol in errorList)
flash(f"Error when adding {studentLabor} to event.", "danger")

if 'ajax' in request.form and request.form['ajax']:
return ''

return redirect(url_for('admin.manageLaborPage', eventID = eventId))

@admin_bp.route("/event/<int:event_id>/scannerentry", methods=["GET", "POST"])
def eventKioskStatus(event_id):
referer = request.referrer
is_labor = False

if referer and "manage_labor" in referer:
is_labor = True
elif referer and "manage_volunteers" in referer:
is_labor = False

event = Event.get_by_id(event_id)
return render_template("/events/eventKiosk.html", is_labor=is_labor, event=event)

@admin_bp.route('/addLaborToEvent/<username>/<eventId>/isBanned', methods = ['GET'])
def isLaborBanned(username, eventId):
return {"banned":1} if isBannedFromEvent(username, eventId) else {"banned":0}
2 changes: 1 addition & 1 deletion app/controllers/admin/userManagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from app.logic.userManagement import changeProgramInfo
from app.logic.utils import selectSurroundingTerms
from app.logic.term import addNextTerm, changeCurrentTerm
from app.logic.volunteers import setProgramManager
from app.logic.participants import setProgramManager
from app.models.attachmentUpload import AttachmentUpload
from app.models.programManager import ProgramManager
from app.models.user import User
Expand Down
19 changes: 10 additions & 9 deletions app/controllers/admin/volunteers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
from app.models.emergencyContact import EmergencyContact
from app.models.insuranceInfo import InsuranceInfo
from app.logic.searchUsers import searchUsers
from app.logic.volunteers import updateEventParticipants, getEventLengthInHours, addUserBackgroundCheck, setProgramManager, deleteUserBackgroundCheck
from app.logic.participants import trainedParticipants, addPersonToEvent, getParticipationStatusForTrainings, sortParticipantsByStatus
from app.logic.participants import updateEventVolunteers, addUserBackgroundCheck, setProgramManager, deleteUserBackgroundCheck
from app.logic.participants import trainedParticipants, addParticipantToEvent, getParticipationStatusForTrainings, sortParticipants
from app.logic.events import getPreviousSeriesEventData, getEventRsvpCount
from app.models.eventRsvp import EventRsvp
from app.models.backgroundCheck import BackgroundCheck
from app.logic.createLogs import createActivityLog, createRsvpLog
from app.logic.users import getBannedUsers, isBannedFromEvent
from app.logic.sharedLogic import getEventLengthInHours


@admin_bp.route('/searchVolunteers/<query>', methods = ['GET'])
Expand All @@ -31,7 +32,7 @@ def manageVolunteersPage(eventID):
Controller that handles POST and GET requests regarding the Manage Volunteers page.

POST: updates the event participants for a particular event by calling
updateEventParticipants on the form.
updateEventVolunteers on the form.

GET: retrieves all necessary participant lists and dictionaries and categorizes
the participants/volunteers into their respective participation statuses. Then
Expand All @@ -45,9 +46,9 @@ def manageVolunteersPage(eventID):

# ------------ POST request ------------
if request.method == "POST":
volunteerUpdated = updateEventParticipants(request.form)
volunteerUpdated = updateEventVolunteers(request.form)

# error handling depending on the boolean returned from updateEventParticipants
# error handling depending on the boolean returned from updateEventVolunteers
if volunteerUpdated:
flash("Volunteer table succesfully updated", "success")
else:
Expand All @@ -64,9 +65,9 @@ def manageVolunteersPage(eventID):

bannedUsersForProgram = [bannedUser.user for bannedUser in getBannedUsers(event.program)]

eventNonAttendedData, eventWaitlistData, eventVolunteerData, eventParticipants = sortParticipantsByStatus(event)
allRelevantUsers = list(set(participant.user for participant in (eventParticipants + eventNonAttendedData + eventWaitlistData + eventVolunteerData)))
eventNonAttendedData, eventWaitlistData, eventVolunteerData, eventVolunteers = sortParticipants(event, False)

allRelevantUsers = list(set(participant.user for participant in (eventVolunteers + eventNonAttendedData + eventWaitlistData + eventVolunteerData)))
# ----------- Get miscellaneous data -----------

participationStatusForTrainings = getParticipationStatusForTrainings(event.program, allRelevantUsers, event.term)
Expand Down Expand Up @@ -135,7 +136,7 @@ def addVolunteer(eventId):

for user in usernameList:
userObj = User.get_by_id(user)
successfullyAddedVolunteer = addPersonToEvent(userObj, event)
successfullyAddedVolunteer = addParticipantToEvent(userObj, event, False)
if successfullyAddedVolunteer == "already in":
alreadyAddedList.append(userObj.fullName)
else:
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/events/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from app.logic.emailHandler import EmailHandler
from app.logic.participants import addBnumberAsParticipant


@events_bp.route('/event/<eventid>/scannerentry', methods=['GET'])
def loadKiosk(eventid):
"""Renders kiosk for specified event."""
Expand All @@ -22,6 +23,8 @@ def loadKiosk(eventid):

@events_bp.route('/signintoEvent', methods=['POST'])
def kioskSignin():
isLabor = request.form.get("isitlabor") == "1"

"""Utilizes form data and sign in function. Returns correct flasher message."""
eventid = request.form["eventid"]
bnumber = request.form["bNumber"]
Expand All @@ -39,7 +42,10 @@ def kioskSignin():
elif bnumber[0].upper() != "B":
return "", 500
try:
kioskUser, userStatus = addBnumberAsParticipant(bnumber, eventid)
if isLabor:
kioskUser, userStatus = addBnumberAsParticipant(bnumber, eventid, True)
else:
kioskUser, userStatus = addBnumberAsParticipant(bnumber, eventid, False)
if kioskUser:
return {"user": f"{kioskUser.firstName} {kioskUser.lastName}", "status": userStatus}
else:
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from app.logic.certification import getCertRequirementsWithCompletion
from app.logic.landingPage import getManagerProgramDict, getActiveEventTab
from app.logic.minor import toggleMinorInterest, declareMinorInterest, getCommunityEngagementByTerm, getEngagementTotal
from app.logic.participants import unattendedRequiredEvents, trainedParticipants, getParticipationStatusForTrainings, checkUserRsvp, addPersonToEvent
from app.logic.participants import unattendedRequiredEvents, trainedParticipants, getParticipationStatusForTrainings, checkUserRsvp, addParticipantToEvent
from app.logic.users import addUserInterest, removeUserInterest, banUser, unbanUser, isEligibleForProgram, getUserBGCheckHistory, addProfileNote, deleteProfileNote, updateDietInfo

@main_bp.route('/logout', methods=['GET'])
Expand Down Expand Up @@ -496,7 +496,7 @@ def volunteerRegister():

personAdded = False
if isEligible:
personAdded = addPersonToEvent(user, event)
personAdded = addParticipantToEvent(user, event, False)
if personAdded and listOfRequirements:
reqListToString = ', '.join(listOfRequirements)
flash(f"{user.firstName} {user.lastName} successfully registered. However, the following training may be required: {reqListToString}.", "success")
Expand Down
Loading