election_day.layouts.default

Classes

HasName

Base class for protocol classes.

DefaultLayout

Extends the base layout class with methods related to chameleon

Module Contents

class election_day.layouts.default.HasName[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...
property name: str[source]
class election_day.layouts.default.DefaultLayout(model: Any, request: onegov.election_day.request.ElectionDayRequest)[source]

Bases: onegov.core.layout.ChameleonLayout

Extends the base layout class with methods related to chameleon template rendering.

This class assumes the existance of two templates:

  • layout.pt -> Contains the page skeleton with headers, body and so on.

  • macros.pt -> Contains chameleon macros.

day_long_format = 'skeleton:MMMMd'[source]
date_long_format = 'long'[source]
datetime_long_format = 'medium'[source]
docs_base_url = 'https://github.com/OneGov/onegov-cloud/blob/master/src/onegov/election_day/static/docs/api'[source]
app: onegov.election_day.app.ElectionDayApp[source]

Returns the application behind the request.

request: onegov.election_day.request.ElectionDayRequest[source]
title() str[source]
property principal: Canton | Municipality[source]
label(value: str) str[source]
property has_districts: bool[source]
property has_regions: bool[source]
property has_superregions: bool[source]
property terms_icon: str[source]
property font_awesome_path: str[source]
property sentry_init_path: str[source]
property copyright_year: int[source]
property archive: onegov.election_day.collections.ArchivedResultCollection[source]
property locales: list[tuple[str, str]][source]
format_name(item: HasName) str[source]
property logo_alt_text: str[source]
property archive_download: str[source]
property last_archive_modification: datetime | None[source]