Naalya Handbook
School features

Elections

How staff publish a ballot, how a student casts one vote per position, and every refusal on the way.

WhoAPI prefixGatesHub screens
Staffelections, elections/:electionId/positionsUser type staff, Feature.ELECTIONS, an election permission per route/staff-hub/campus/$campusId/elections
Studentstudent/electionsUser type student, Feature.ELECTIONS, no permission decorator/student/elections

Writes also need the election's campus year to be unlocked. Paths start with /api/v1; every route is in the route reference.

Setting up and publishing

Create. POST /elections (createElection) stores a draft. isAnonymous defaults to false. The year must be current or future and unlocked, and endsAt must be after startsAt.

Add positions and candidates while it's a draft. A position with no streamIds is open to the whole campus year; with streams, only those streams can vote. A candidate must be actively enrolled in the election's campus year.

Publish. POST /elections/:id/publish (publishElection, update) sets published and publishedAt.

Close. POST /elections/:id/close (closeElection) sets closed and closedAt, whatever endsAt says.

Release results. POST /elections/:id/release-results (releaseElectionResults) sets resultsReleasedAt. Status stays closed. There is no un-release.

Election refusals

WhenMessage
Create with a backwards windowendsAt must be after startsAt
Publish a non-draftOnly draft elections can be published
Publish after endsAtVoting window has already ended
Publish with no positionsAdd at least one position before publishing
Publish with an empty positionEvery position needs at least one candidate before publishing
Close a non-published electionOnly published elections can be closed
Release before closingClose the election before releasing results
Release twiceResults already released
Patch a published election other than endsAtA published election only allows extending endsAt
Move endsAt earlierendsAt can only be extended; close the election to end voting early
Edit a closed electionClosed elections cannot be edited
Delete a non-draftOnly draft elections can be deleted (drafts are soft-deleted)
Tallies on a draftDraft elections have no tallies
Unknown idElection not found

Position and candidate refusals

All of these routes need the election to be a draft (Only draft elections can be edited).

RouteWhenMessage
createElectionPositionName already used in this electionA position with this name already exists in this election (409)
createElectionPosition, updateElectionPositionA stream id doesn't existOne or more streams do not exist
A stream's class is on another campusStream does not belong to this campus
updateElectionPosition, candidate PATCHBody changes nothingNo changes provided
Position routesPosition missing or on another electionPosition not found
addElectionCandidateNo such enrollmentEnrollment not found
Enrollment not activeCandidate enrollment is not active
Another campus or yearCandidate must be actively enrolled in this election's campus year
Already a candidate hereThis student is already a candidate for this position (409)
Candidate routesCandidate on another positionCandidate not found

Deleting a position or candidate is a soft delete. Sending streamIds on update replaces the targeting.

Casting a vote

List. GET /student/elections (listMyElections) returns published elections whose window contains now, across the student's active enrollments.

Open the ballot. GET /student/elections/:electionId/ballot (getMyBallot) returns positions with hasVoted and isOpen. Drafts are Election not found; closed ones come back with isOpen false. Anonymous elections omit votedCandidateId.

Vote. POST /student/elections/:electionId/positions/:positionId/vote (castElectionVote) with { "candidateId" }. The voter receipt (election_position_voter) and the ballot row are written in one transaction; an anonymous ballot stores voterEnrollmentId as null.

WhenMessage
No student profileStudent profile not found
No active enrollment for the election's campus yearYou are not enrolled for this election
Election missing or draftElection not found
Not published, or outside the windowVoting is not open for this election
Position missing or on another electionPosition not found
Position limited to streams that exclude the studentThis position is not open to your stream
Candidate not on that positionCandidate does not belong to this position
Already voted, including a unique-violation race (23505)You have already voted for this position

The audit entry records that a vote was cast but not the response, so the chosen candidate is not in the audit snapshot.

Results. GET /student/elections/results lists elections with resultsReleasedAt set; GET /student/elections/:electionId/results throws Results are not available until then. Counts are ballot rows per candidate, with no voter names.

Hub screens

ScreenRouteWhat it does
Staff liststaff-hub/campus/$campusId/electionsElections for the viewing year; create surface; "No elections this year" when empty
Staff election.../elections/$electionIdEdit, Publish, Close, Release results, Extend close time, Delete draft, add positions
Staff position and candidate.../positions/$positionId, .../candidates/$candidateIdManage candidates; remove a candidate
Staff tallies.../elections/$electionId/talliesCounts per candidate
Student liststudent/electionsOpen elections with voted count; released ones link to results
Student ballotstudent/elections/$electionIdOpen or Closed, Secret or Open ballot; each position shows Voted, To vote or Missed
Student position.../positions/$positionIdPick a candidate, press "Cast vote"; a secret vote shows "Vote recorded" without a name
Student resultsstudent/elections/$electionId/resultsReleased counts; "Results unavailable" otherwise

The old student candidate URL (.../candidates/$candidateId) now redirects to the position screen.

On this page