ballot.models.vote.ballot

Module Contents

Classes

ResultsByDistrictRow

Ballot

A ballot contains a single question asked for a vote.

class ballot.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 ballot.models.vote.ballot.Ballot[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.TimestampMixin, onegov.ballot.models.mixins.TitleTranslationsMixin, onegov.ballot.models.vote.mixins.DerivedAttributesMixin, onegov.ballot.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.

property polymorphic_base: type[Ballot][source]
property results_by_district: Query[ResultsByDistrictRow][source]

Returns the results aggregated by the distict.

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]
__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]
yeas[source]
nays[source]
empty[source]
invalid[source]
eligible_voters[source]
expats[source]
counted() bool[source]

True if all results have been counted.

counted() ColumnElement[bool][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.