election_day.models.vote.ballot

Classes

ResultsByDistrictRow

Ballot

A ballot contains a single question asked for a vote.

Module Contents

class election_day.models.vote.ballot.ResultsByDistrictRow[source]

Bases: NamedTuple

name: str[source]
counted: bool[source]
accepted: bool[source]
yeas: int[source]
nays: int[source]
yeas_percentage: float[source]
nays_percentage: float[source]
empty: int[source]
invalid: int[source]
eligible_voters: int[source]
entity_ids: list[int][source]
class election_day.models.vote.ballot.Ballot[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.TimestampMixin, onegov.election_day.models.mixins.TitleTranslationsMixin, onegov.election_day.models.vote.mixins.DerivedAttributesMixin, onegov.election_day.models.vote.mixins.DerivedBallotsCountMixin

A ballot contains a single question asked for a vote.

Usually each vote has exactly one ballot, but it’s possible for votes to have multiple ballots.

In the latter case there are usually two options that are mutually exclusive and a third option that acts as a tie breaker between the frist two options.

The type of the ballot indicates this. Standard ballots only contain one question, variant ballots contain multiple questions.

__tablename__ = 'ballots'[source]
id: Column[uuid.UUID][source]
external_id: Column[str | None][source]
type: Column[BallotType][source]
vote_id: Column[str][source]
title_translations: Column[Mapping[str, str] | None][source]
title[source]
results: relationship[list[BallotResult]][source]
vote: relationship[Vote][source]
property results_by_district: Query[ResultsByDistrictRow][source]

Returns the results aggregated by the distict.

counted: sqlalchemy.Column[bool][source]
property progress: tuple[int, int][source]

Returns a tuple with the first value being the number of counted ballot results and the second value being the number of total ballot results.

property answer: str | None[source]
yeas[source]
nays[source]
empty[source]
invalid[source]
eligible_voters[source]
expats[source]
aggregate_results(attribute: str) int[source]

Gets the sum of the given attribute from the results.

classmethod aggregate_results_expression(attribute: str) ColumnElement[int][source]

Gets the sum of the given attribute from the results, as SQL expression.

clear_results(clear_all: bool = False) None[source]

Clear all the results.