landsgemeinde.utils

Module Contents

Functions

update_ticker(→ None)

Updates the ticker by a set of updated assemblies, agenda items or

ensure_states(...)

Ensure that all the states are meaningful when changing the state of

timestamp_to_seconds(→ int | None)

Convert a timestamp to seconds.

seconds_to_timestamp(→ str | None)

Convert seconds to a timestamp.

landsgemeinde.utils.update_ticker(request: onegov.landsgemeinde.request.LandsgemeindeRequest, updated: Collection[Assembly | AgendaItem | Votum]) None[source]

Updates the ticker by a set of updated assemblies, agenda items or vota.

Sends either a ‘refresh’ event to reload the whole ticker (in case the assembly has been changed or an agenda item has been added/deleted) or and ‘update’ event with the changed content of the agenda item.

Provide an assembly to ensure, that the whole ticker is reloaded.

Also sets the modified timestamp on the assembly used for the polling fallback.

landsgemeinde.utils.ensure_states(item: onegov.landsgemeinde.models.Assembly | onegov.landsgemeinde.models.AgendaItem | onegov.landsgemeinde.models.Votum) set[onegov.landsgemeinde.models.Assembly | onegov.landsgemeinde.models.AgendaItem | onegov.landsgemeinde.models.Votum][source]

Ensure that all the states are meaningful when changing the state of an assembly, agenda item or votum.

Also sets and clears the start time of agenda items.

Returns a set with updated assemblies, agenda items and vota.

landsgemeinde.utils.timestamp_to_seconds(timestamp: str | None) int | None[source]

Convert a timestamp to seconds.

Examples: ‘1m30s’ -> 90 ’30s’ -> 30 ‘1h2m30s’ -> 3750

landsgemeinde.utils.seconds_to_timestamp(seconds: int | None) str | None[source]

Convert seconds to a timestamp.

Examples: 90 -> ‘1m30s’ 30 -> ’30s’ 3750 -> ‘1h2m30s’