election_day.models.notification

Classes

Notification

Stores triggered notifications.

WebhookNotification

Stores triggered notifications.

EmailNotification

Stores triggered notifications.

SmsNotification

Stores triggered notifications.

Module Contents

class election_day.models.notification.Notification[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.TimestampMixin

Stores triggered notifications.

__tablename__ = 'notifications'[source]
type: Column[str][source]
__mapper_args__[source]
id: Column[uuid.UUID][source]
last_modified: Column[datetime | None][source]
election_id: Column[str | None][source]
election: relationship[Election | None][source]
election_compound_id: Column[str | None][source]
election_compound: relationship[ElectionCompound | None][source]
vote_id: Column[str | None][source]
vote: relationship[Vote | None][source]
update_from_model(model: onegov.election_day.models.election.Election | onegov.election_day.models.election_compound.ElectionCompound | onegov.election_day.models.vote.Vote) None[source]

Copy

abstract trigger(request: onegov.election_day.request.ElectionDayRequest, model: onegov.election_day.models.election.Election | onegov.election_day.models.election_compound.ElectionCompound | onegov.election_day.models.vote.Vote) None[source]

Trigger the custom actions.

class election_day.models.notification.WebhookNotification[source]

Bases: Notification

Stores triggered notifications.

__mapper_args__[source]
trigger(request: onegov.election_day.request.ElectionDayRequest, model: onegov.election_day.models.election.Election | onegov.election_day.models.election_compound.ElectionCompound | onegov.election_day.models.vote.Vote) None[source]

Posts the summary of the given vote or election to the webhook URL defined for this principal.

This only works for external URLs. If posting to the server itself is needed, use a process instead of the thread:

process = Process(target=send_post_request, args=(urls, data)) process.start()

class election_day.models.notification.EmailNotification[source]

Bases: Notification

Stores triggered notifications.

__mapper_args__[source]
set_locale(request: onegov.election_day.request.ElectionDayRequest, locale: str | None = None) None[source]

Changes the locale of the request.

(Re)stores the intial locale if no locale is given.

send_emails(request: onegov.election_day.request.ElectionDayRequest, elections: Sequence[Election], election_compounds: Sequence[ElectionCompound], votes: Sequence[Vote], subject: str | None = None) None[source]

Sends the results of the vote or election to all subscribers.

Adds unsubscribe headers (RFC 2369, RFC 8058).

trigger(request: onegov.election_day.request.ElectionDayRequest, model: onegov.election_day.models.election.Election | onegov.election_day.models.election_compound.ElectionCompound | onegov.election_day.models.vote.Vote) None[source]

Sends the results of the vote, election or election compound to all subscribers.

Adds unsubscribe headers (RFC 2369, RFC 8058).

class election_day.models.notification.SmsNotification[source]

Bases: Notification

Stores triggered notifications.

__mapper_args__[source]
send_sms(request: onegov.election_day.request.ElectionDayRequest, elections: Sequence[Election], election_compounds: Sequence[ElectionCompound], votes: Sequence[Vote], content: translationstring.TranslationString, url: str | None = None) None[source]

Sends the given text to all subscribers.

trigger(request: onegov.election_day.request.ElectionDayRequest, model: onegov.election_day.models.election.Election | onegov.election_day.models.election_compound.ElectionCompound | onegov.election_day.models.vote.Vote) None[source]

Posts a link to the vote or election to all subscribers.

This is done by writing files to a directory similary to maildir, sending the SMS is done using an external command, probably called by a cronjob.