election_day.collections.subscribers ==================================== .. py:module:: election_day.collections.subscribers Attributes ---------- .. autoapisummary:: election_day.collections.subscribers._S Classes ------- .. autoapisummary:: election_day.collections.subscribers.SubscriberCollection election_day.collections.subscribers.EmailSubscriberCollection election_day.collections.subscribers.SmsSubscriberCollection Module Contents --------------- .. py:data:: _S .. py:class:: SubscriberCollection(session: sqlalchemy.orm.Session, page: int = 0, term: str | None = None, active_only: bool | None = True) Bases: :py:obj:`onegov.core.collection.Pagination`\ [\ :py:obj:`_S`\ ] Provides collections with pagination, if they implement a few documented properties and methods. See :class:`onegov.ticket.TicketCollection` for an example. .. py:attribute:: page :type: int .. py:attribute:: session .. py:attribute:: term :value: None .. py:attribute:: active_only :value: True .. py:property:: model_class :type: type[_S] .. py:method:: __eq__(other: object) -> bool Returns True if the current and the other Pagination instance are equal. Used to find the current page in a list of pages. .. py:method:: subset() -> sqlalchemy.orm.Query[_S] Returns an SQLAlchemy query containing all records that should be considered for pagination. .. py:property:: page_index :type: int Returns the current page index (starting at 0). .. py:method:: page_by_index(index: int) -> Self Returns the page at the given index. A page here means an instance of the class inheriting from the ``Pagination`` base class. .. py:method:: for_active_only(active_only: bool) -> Self .. py:method:: add(address: str, domain: str | None, domain_segment: str | None, locale: str, active: bool) -> _S .. py:method:: query(active_only: bool | None = None) -> sqlalchemy.orm.Query[_S] .. py:method:: by_id(id: uuid.UUID) -> _S | None Returns the subscriber by its id. .. py:method:: by_address(address: str, domain: str | None, domain_segment: str | None) -> _S | None Returns the (first) subscriber by its address. .. py:method:: initiate_subscription(address: str, domain: str | None, domain_segment: str | None, request: onegov.election_day.request.ElectionDayRequest) -> _S Initiate the subscription process. Might be used to change the locale by re-subscribing. .. py:method:: handle_subscription(subscriber: _S, domain: str | None, domain_segment: str | None, request: onegov.election_day.request.ElectionDayRequest) -> None :abstractmethod: Send the subscriber a request to confirm the subscription. .. py:method:: initiate_unsubscription(address: str, domain: str | None, domain_segment: str | None, request: onegov.election_day.request.ElectionDayRequest) -> None Initiate the unsubscription process. .. py:method:: handle_unsubscription(subscriber: _S, request: onegov.election_day.request.ElectionDayRequest) -> None :abstractmethod: Send the subscriber a request to confirm the unsubscription. .. py:method:: export() -> list[dict[str, Any]] Returns all data connected to these subscribers. .. py:method:: cleanup(file: IO[bytes], mimetype: str, delete: bool) -> tuple[list[onegov.election_day.formats.imports.common.FileImportError], int] Disables or deletes the subscribers in the given CSV. Ignores domain and domain segment, as this is inteded to cleanup bounced addresses. .. py:class:: EmailSubscriberCollection(session: sqlalchemy.orm.Session, page: int = 0, term: str | None = None, active_only: bool | None = True) Bases: :py:obj:`SubscriberCollection`\ [\ :py:obj:`onegov.election_day.models.EmailSubscriber`\ ] Provides collections with pagination, if they implement a few documented properties and methods. See :class:`onegov.ticket.TicketCollection` for an example. .. py:property:: model_class :type: type[onegov.election_day.models.EmailSubscriber] .. py:method:: handle_subscription(subscriber: onegov.election_day.models.EmailSubscriber, domain: str | None, domain_segment: str | None, request: onegov.election_day.request.ElectionDayRequest) -> None Send the (new) subscriber a request to confirm the subscription. .. py:method:: confirm_subscription(address: str, domain: str | None, domain_segment: str | None, locale: str) -> bool Confirm the subscription. .. py:method:: handle_unsubscription(subscriber: onegov.election_day.models.EmailSubscriber, request: onegov.election_day.request.ElectionDayRequest) -> None Send the subscriber a request to confirm the unsubscription. .. py:method:: confirm_unsubscription(address: str, domain: str | None, domain_segment: str | None) -> bool Confirm the unsubscription. .. py:class:: SmsSubscriberCollection(session: sqlalchemy.orm.Session, page: int = 0, term: str | None = None, active_only: bool | None = True) Bases: :py:obj:`SubscriberCollection`\ [\ :py:obj:`onegov.election_day.models.SmsSubscriber`\ ] Provides collections with pagination, if they implement a few documented properties and methods. See :class:`onegov.ticket.TicketCollection` for an example. .. py:property:: model_class :type: type[onegov.election_day.models.SmsSubscriber] .. py:method:: handle_subscription(subscriber: onegov.election_day.models.SmsSubscriber, domain: str | None, domain_segment: str | None, request: onegov.election_day.request.ElectionDayRequest) -> None Confirm the subscription by sending an SMS (if not already subscribed). There is no double-opt-in for SMS subscribers. .. py:method:: handle_unsubscription(subscriber: onegov.election_day.models.SmsSubscriber, request: onegov.election_day.request.ElectionDayRequest) -> None Deactivate the subscriber. There is no double-opt-out for SMS subscribers.