election_day.models.vote.vote

Classes

Vote

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

Module Contents

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

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

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

__tablename__ = 'votes'[source]
property polymorphic_base: type[Vote][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]
short_title_translations: Column[Mapping[str, str] | None][source]
short_title[source]
title_observer(title_translations: Mapping[str, str], short_title_translations: Mapping[str, str]) None[source]
date: Column[datetime.date][source]
ballots: relationship[list[Ballot]][source]
ballot(ballot_type: onegov.election_day.types.BallotType) onegov.election_day.models.vote.ballot.Ballot[source]

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

property proposal: onegov.election_day.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.

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.

last_ballot_change: sqlalchemy.Column[datetime.datetime | None][source]
last_modified() datetime.datetime | None[source]

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

data_sources: relationship[list[DataSourceItem]][source]
notifications: relationship[AppenderQuery[Notification]][source]
screens: relationship[AppenderQuery[Screen]][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]
direct: onegov.core.orm.mixins.dict_property[bool][source]
clear_results(clear_all: bool = False) None[source]

Clear all the results.