ballot.models.vote.vote

Module Contents

Classes

Vote

A vote describes the issue being voted on. For example,

class ballot.models.vote.vote.Vote[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.ContentMixin, onegov.ballot.models.mixins.LastModifiedMixin, onegov.ballot.models.mixins.DomainOfInfluenceMixin, onegov.ballot.models.mixins.StatusMixin, onegov.ballot.models.mixins.TitleTranslationsMixin, onegov.ballot.models.vote.mixins.DerivedBallotsCountMixin, onegov.ballot.models.mixins.ExplanationsPdfMixin

A vote describes the issue being voted on. For example, “Vote for Net Neutrality” or “Vote for Basic Income”.

property polymorphic_base: type[Vote][source]
property proposal: onegov.ballot.models.vote.ballot.Ballot[source]
property counted: bool[source]

Checks if there are results for all entities.

property has_results: bool[source]

Returns True, if there are any results.

property answer: str | None[source]
property yeas_percentage: float[source]

The percentage of yeas (discounts empty/invalid ballots).

property nays_percentage: float[source]

The percentage of nays (discounts empty/invalid ballots).

property progress: tuple[int, int][source]

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

For complex votes, it is assumed that every ballot has the same progress.

property counted_entities: list[str][source]

Returns the names of the already counted entities.

Might contain an empty string in case of expats.

For complex votes, it is assumed that every ballot has the same progress.

__tablename__ = 'votes'[source]
type: Column[str][source]
__mapper_args__[source]
id: Column[str][source]
external_id: Column[str | None][source]
shortcode: Column[str | None][source]
title_translations: Column[Mapping[str, str]][source]
title[source]
date: Column[datetime.date][source]
ballots: relationship[list[Ballot]][source]
yeas[source]
nays[source]
empty[source]
invalid[source]
eligible_voters[source]
expats[source]
has_expats: onegov.core.orm.mixins.dict_property[bool][source]
domain_segment: onegov.core.orm.mixins.dict_property[str][source]
tie_breaker_vocabulary: onegov.core.orm.mixins.dict_property[bool][source]
title_observer(translations: Mapping[str, str]) None[source]
ballot(ballot_type: onegov.ballot.types.BallotType) onegov.ballot.models.vote.ballot.Ballot[source]

Returns the given ballot if it exists, creates it if not.

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.

last_ballot_change() datetime.datetime | None[source]

Returns last change of the vote, its ballots and any of its results.

last_ballot_change() ColumnElement[datetime.datetime | None][source]
last_modified() datetime.datetime | None[source]

Returns last change of the vote, its ballots and any of its results.

last_modified() ColumnElement[datetime.datetime | None][source]
clear_results(clear_all: bool = False) None[source]

Clear all the results.