election_day.models.notification ================================ .. py:module:: election_day.models.notification Classes ------- .. autoapisummary:: election_day.models.notification.Notification election_day.models.notification.WebhookNotification election_day.models.notification.EmailNotification election_day.models.notification.SmsNotification Module Contents --------------- .. py:class:: Notification Bases: :py:obj:`onegov.core.orm.Base`, :py:obj:`onegov.core.orm.mixins.TimestampMixin` Stores triggered notifications. .. py:attribute:: __tablename__ :value: 'notifications' .. py:attribute:: type :type: sqlalchemy.Column[str] .. py:attribute:: __mapper_args__ .. py:attribute:: id :type: sqlalchemy.Column[uuid.UUID] .. py:attribute:: last_modified :type: sqlalchemy.Column[datetime.datetime | None] .. py:attribute:: election_id :type: sqlalchemy.Column[str | None] .. py:attribute:: election :type: sqlalchemy.orm.relationship[onegov.election_day.models.election.Election | None] .. py:attribute:: election_compound_id :type: sqlalchemy.Column[str | None] .. py:attribute:: election_compound :type: sqlalchemy.orm.relationship[onegov.election_day.models.election_compound.ElectionCompound | None] .. py:attribute:: vote_id :type: sqlalchemy.Column[str | None] .. py:attribute:: vote :type: sqlalchemy.orm.relationship[onegov.election_day.models.vote.Vote | None] .. py:method:: update_from_model(model: onegov.election_day.models.election.Election | onegov.election_day.models.election_compound.ElectionCompound | onegov.election_day.models.vote.Vote) -> None Copy .. py:method:: 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 :abstractmethod: Trigger the custom actions. .. py:class:: WebhookNotification Bases: :py:obj:`Notification` Stores triggered notifications. .. py:attribute:: __mapper_args__ .. py:method:: 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 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() .. py:class:: EmailNotification Bases: :py:obj:`Notification` Stores triggered notifications. .. py:attribute:: __mapper_args__ .. py:method:: set_locale(request: onegov.election_day.request.ElectionDayRequest, locale: str | None = None) -> None Changes the locale of the request. (Re)stores the intial locale if no locale is given. .. py:method:: send_emails(request: onegov.election_day.request.ElectionDayRequest, elections: collections.abc.Sequence[onegov.election_day.models.election.Election], election_compounds: collections.abc.Sequence[onegov.election_day.models.election_compound.ElectionCompound], votes: collections.abc.Sequence[onegov.election_day.models.vote.Vote], subject: str | None = None) -> None Sends the results of the vote or election to all subscribers. Adds unsubscribe headers (RFC 2369, RFC 8058). .. py:method:: 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 Sends the results of the vote, election or election compound to all subscribers. Adds unsubscribe headers (RFC 2369, RFC 8058). .. py:class:: SmsNotification Bases: :py:obj:`Notification` Stores triggered notifications. .. py:attribute:: __mapper_args__ .. py:method:: send_sms(request: onegov.election_day.request.ElectionDayRequest, elections: collections.abc.Sequence[onegov.election_day.models.election.Election], election_compounds: collections.abc.Sequence[onegov.election_day.models.election_compound.ElectionCompound], votes: collections.abc.Sequence[onegov.election_day.models.vote.Vote], content: translationstring.TranslationString, url: str | None = None) -> None Sends the given text to all subscribers. .. py:method:: 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 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.