election_day.models.principal

Classes

Principal

The principal is the political entity running the election day app.

Canton

A cantonal instance.

Municipality

A communal instance.

Module Contents

class election_day.models.principal.Principal(id_: str, domain: str, domains_election: dict[str, translationstring.TranslationString], domains_vote: dict[str, translationstring.TranslationString], entities: dict[int, dict[int, dict[str, str]]], name: str | None = None, logo: str | None = None, logo_position: str = 'left', color: str = '#000', base: str | None = None, analytics: str | None = None, has_districts: bool = True, has_regions: bool = False, has_superregions: bool = False, use_maps: bool = False, fetch: dict[str, Any] | None = None, webhooks: dict[str, dict[str, str]] | None = None, sms_notification: bool | None = None, email_notification: bool | None = None, wabsti_import: bool = False, open_data: dict[str, str] | None = None, hidden_elements: dict[str, dict[str, dict[str, bool]]] | None = None, publish_intermediate_results: dict[str, bool] | None = None, csp_script_src: list[str] | None = None, csp_connect_src: list[str] | None = None, cache_expiration_time: int = 300, reply_to: str | None = None, custom_css: str | None = None, official_host: str | None = None, segmented_notifications: bool = False, private: bool = False, **kwargs: Never)[source]

The principal is the political entity running the election day app.

There are currently two different types of principals supported: Cantons and Municipalitites.

A principal is identitifed by its ID (municipalitites: BFS number, cantons: canton code).

A principal may consist of different entities (municipalitites: quarters, cantons: municipalities) grouped by districts. Some cantons have regions for certain years, an additional type of district only used for regional elections (Kantonsratswahl, Grossratswahl, Landratswahl). Some of them have superregions which further aggregate these regions. The label of the entity, the districts, regions and superregions may vary and can be queried with label.

A principal is part of a domain (municipalitites: municipality, canton: canton) and supports different types of domains (typically all higher domains).

hidden_elements: Used to optionally show and hide certain charts on the defined views.

Example config in a yaml file:

hidden_elements:
  always:
    candidate-by-entity:
      chart_percentages: true
  intermediate_results:
    connections:
      chart: false
    candidates:
      chart: false

publish_intermediate_results: Optionally renders svg and pdf for intermediate results. Example:

publish_intermediate_results:
  vote: true
  election: true
  election_compound: true

Defaults to false if nothing specified

id[source]
domain[source]
domains_election[source]
domains_vote[source]
entities[source]
name[source]
logo_position[source]
color[source]
base[source]
analytics[source]
has_districts[source]
has_regions[source]
has_superregions[source]
use_maps[source]
fetch[source]
webhooks[source]
sms_notification[source]
email_notification[source]
wabsti_import[source]
open_data[source]
hidden_elements[source]
publish_intermediate_results[source]
csp_script_src[source]
csp_connect_src[source]
cache_expiration_time[source]
reply_to[source]
custom_css[source]
official_host[source]
segmented_notifications[source]
private[source]
classmethod from_yaml(yaml_source: yaml.reader._ReadStream) Canton | Municipality[source]
property base_domain: str | None[source]
is_year_available(year: int, map_required: bool = True) bool[source]
get_entities(year: int) set[str][source]
get_districts(year: int) set[str][source]
get_regions(year: int) set[str][source]
get_superregion(region: str, year: int) str[source]
get_superregions(year: int) set[str][source]
abstract label(value: str) str[source]
class election_day.models.principal.Canton(canton: str, **kwargs: Any)[source]

Bases: Principal

A cantonal instance.

CANTONS[source]
domain: Literal['canton'][source]
id[source]
label(value: str) str[source]
class election_day.models.principal.Municipality(municipality: str, canton: str, canton_name: str, **kwargs: Any)[source]

Bases: Principal

A communal instance.

domain: Literal['municipality'][source]
canton[source]
canton_name[source]
label(value: str) str[source]