election_day.collections.subscribers

Attributes

_S

Classes

SubscriberCollection

Provides collections with pagination, if they implement a few

EmailSubscriberCollection

Provides collections with pagination, if they implement a few

SmsSubscriberCollection

Provides collections with pagination, if they implement a few

Module Contents

election_day.collections.subscribers._S[source]
class election_day.collections.subscribers.SubscriberCollection(session: sqlalchemy.orm.Session, page: int = 0, term: str | None = None, active_only: bool | None = True)[source]

Bases: onegov.core.collection.Pagination[_S]

Provides collections with pagination, if they implement a few documented properties and methods.

See onegov.ticket.TicketCollection for an example.

page: int[source]
property model_class: type[_S][source]
__eq__(other: object) bool[source]

Returns True if the current and the other Pagination instance are equal. Used to find the current page in a list of pages.

subset() Query[_S][source]

Returns an SQLAlchemy query containing all records that should be considered for pagination.

property page_index: int[source]

Returns the current page index (starting at 0).

page_by_index(index: int) typing_extensions.Self[source]

Returns the page at the given index. A page here means an instance of the class inheriting from the Pagination base class.

for_active_only(active_only: bool) typing_extensions.Self[source]
add(address: str, domain: str | None, domain_segment: str | None, locale: str, active: bool) _S[source]
query(active_only: bool | None = None) Query[_S][source]
by_id(id: uuid.UUID) _S | None[source]

Returns the subscriber by its id.

by_address(address: str, domain: str | None, domain_segment: str | None) _S | None[source]

Returns the (first) subscriber by its address.

initiate_subscription(address: str, domain: str | None, domain_segment: str | None, request: onegov.election_day.request.ElectionDayRequest) _S[source]

Initiate the subscription process.

Might be used to change the locale by re-subscribing.

abstract handle_subscription(subscriber: _S, domain: str | None, domain_segment: str | None, request: onegov.election_day.request.ElectionDayRequest) None[source]

Send the subscriber a request to confirm the subscription.

initiate_unsubscription(address: str, domain: str | None, domain_segment: str | None, request: onegov.election_day.request.ElectionDayRequest) None[source]

Initiate the unsubscription process.

abstract handle_unsubscription(subscriber: _S, request: onegov.election_day.request.ElectionDayRequest) None[source]

Send the subscriber a request to confirm the unsubscription.

export() list[dict[str, Any]][source]

Returns all data connected to these subscribers.

cleanup(file: IO[bytes], mimetype: str, delete: bool) tuple[list[onegov.election_day.formats.imports.common.FileImportError], int][source]

Disables or deletes the subscribers in the given CSV.

Ignores domain and domain segment, as this is inteded to cleanup bounced addresses.

class election_day.collections.subscribers.EmailSubscriberCollection(session: sqlalchemy.orm.Session, page: int = 0, term: str | None = None, active_only: bool | None = True)[source]

Bases: SubscriberCollection[onegov.election_day.models.EmailSubscriber]

Provides collections with pagination, if they implement a few documented properties and methods.

See onegov.ticket.TicketCollection for an example.

property model_class: type[onegov.election_day.models.EmailSubscriber][source]
handle_subscription(subscriber: onegov.election_day.models.EmailSubscriber, domain: str | None, domain_segment: str | None, request: onegov.election_day.request.ElectionDayRequest) None[source]

Send the (new) subscriber a request to confirm the subscription.

confirm_subscription(address: str, domain: str | None, domain_segment: str | None, locale: str) bool[source]

Confirm the subscription.

handle_unsubscription(subscriber: onegov.election_day.models.EmailSubscriber, request: onegov.election_day.request.ElectionDayRequest) None[source]

Send the subscriber a request to confirm the unsubscription.

confirm_unsubscription(address: str, domain: str | None, domain_segment: str | None) bool[source]

Confirm the unsubscription.

class election_day.collections.subscribers.SmsSubscriberCollection(session: sqlalchemy.orm.Session, page: int = 0, term: str | None = None, active_only: bool | None = True)[source]

Bases: SubscriberCollection[onegov.election_day.models.SmsSubscriber]

Provides collections with pagination, if they implement a few documented properties and methods.

See onegov.ticket.TicketCollection for an example.

property model_class: type[onegov.election_day.models.SmsSubscriber][source]
handle_subscription(subscriber: onegov.election_day.models.SmsSubscriber, domain: str | None, domain_segment: str | None, request: onegov.election_day.request.ElectionDayRequest) None[source]

Confirm the subscription by sending an SMS (if not already subscribed). There is no double-opt-in for SMS subscribers.

handle_unsubscription(subscriber: onegov.election_day.models.SmsSubscriber, request: onegov.election_day.request.ElectionDayRequest) None[source]

Deactivate the subscriber. There is no double-opt-out for SMS subscribers.