election_day.models.principal ============================= .. py:module:: election_day.models.principal Classes ------- .. autoapisummary:: election_day.models.principal.Principal election_day.models.principal.Canton election_day.models.principal.Municipality election_day.models.principal.MunicipalityRedirect Module Contents --------------- .. py:class:: 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: str | 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, og_description: str | None = None, **kwargs: Never) 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 og_description: Optional Open Graph description shown in social media link previews. If omitted, no og:description meta tag is rendered. Example:: og_description: "Wahlen und Abstimmungen des Kantons Zug" .. py:attribute:: id .. py:attribute:: domain .. py:attribute:: domains_election .. py:attribute:: domains_vote .. py:attribute:: entities .. py:attribute:: name .. py:attribute:: logo :value: None .. py:attribute:: logo_position :value: 'left' .. py:attribute:: color :value: '#000' .. py:attribute:: base :value: None .. py:attribute:: analytics .. py:attribute:: has_districts :value: True .. py:attribute:: has_regions :value: False .. py:attribute:: has_superregions :value: False .. py:attribute:: use_maps :value: False .. py:attribute:: fetch .. py:attribute:: webhooks .. py:attribute:: sms_notification :value: None .. py:attribute:: email_notification :value: None .. py:attribute:: wabsti_import :value: False .. py:attribute:: open_data .. py:attribute:: hidden_elements .. py:attribute:: publish_intermediate_results .. py:attribute:: csp_script_src :value: [] .. py:attribute:: csp_connect_src :value: [] .. py:attribute:: cache_expiration_time :value: 300 .. py:attribute:: reply_to :value: None .. py:attribute:: custom_css :value: None .. py:attribute:: official_host :value: None .. py:attribute:: segmented_notifications :value: False .. py:attribute:: private :value: False .. py:attribute:: og_description :value: None .. py:method:: from_yaml(yaml_source: yaml.reader._ReadStream) -> Canton | Municipality :classmethod: .. py:property:: base_domain :type: str | None .. py:method:: is_year_available(year: int, map_required: bool = True) -> bool .. py:property:: municipality_display_name_by_slug :type: dict[str, str] Maps sanitized slug → display name, built once from static entities based on the latest year. .. py:method:: get_entities(year: int) -> set[str] .. py:method:: get_districts(year: int) -> set[str] .. py:method:: get_regions(year: int) -> set[str] .. py:method:: get_superregion(region: str, year: int) -> str .. py:method:: get_superregions(year: int) -> set[str] .. py:method:: label(value: str) -> str :abstractmethod: .. py:class:: Canton(canton: str, **kwargs: Any) Bases: :py:obj:`Principal`, :py:obj:`onegov.core.custom.msgpack.Serializable` A cantonal instance. .. py:attribute:: CANTONS .. py:attribute:: domain :type: Literal['canton'] .. py:attribute:: canton .. py:method:: from_dict(canton: 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, fetch: dict[str, Any] | None = None, webhooks: dict[str, dict[str, str]] | None = None, sms_notification: str | 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, og_description: str | None = None, **kwargs: Never) -> Self :classmethod: .. py:method:: label(value: str) -> str .. py:class:: Municipality(municipality: str, canton: str, canton_name: str, **kwargs: Any) Bases: :py:obj:`Principal`, :py:obj:`onegov.core.custom.msgpack.Serializable` A communal instance. .. py:attribute:: domain :type: Literal['municipality'] .. py:attribute:: municipality .. py:attribute:: canton .. py:attribute:: canton_name .. py:method:: from_dict(municipality: str, canton: str, canton_name: 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, has_quarters: bool = False, use_maps: bool = False, fetch: dict[str, Any] | None = None, webhooks: dict[str, dict[str, str]] | None = None, sms_notification: str | 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, private: bool = False, og_description: str | None = None, **kwargs: Never) -> Self :classmethod: .. py:method:: label(value: str) -> str .. py:class:: MunicipalityRedirect(municipality: str) .. py:attribute:: municipality