newsletter.models

Attributes

newsletter_recipients

Classes

Newsletter

Represents a newsletter before and after it is sent.

Recipient

Represents a single recipient.

Subscription

Adds subscription management to a recipient.

Module Contents

newsletter.models.newsletter_recipients[source]
class newsletter.models.Newsletter[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.ContentMixin, onegov.core.orm.mixins.TimestampMixin, onegov.search.SearchableContent

Represents a newsletter before and after it is sent.

A newsletter basically consists of a title/subject, a content and a number of recipients. We assume that all newsletters are sent in HTML using onegov.core, which automatically creates a text representation.

__tablename__ = 'newsletters'[source]
es_id = 'name'[source]

The name of the id attribute (not the actual value!).

If you use this on an ORM model, be sure to use a primary key, all other properties are not available during deletion.

es_properties[source]
property es_public: bool[source]

Returns True if the model is available to be found by the public. If false, only editors/admins will see this object in the search results.

name: sqlalchemy.Column[str][source]
validate_name(key: str, name: str) str[source]
title: sqlalchemy.Column[str][source]
lead: sqlalchemy.Column[str | None][source]
html: sqlalchemy.Column[str][source]
closing_remark[source]
sent: sqlalchemy.Column[datetime.datetime | None][source]
scheduled: sqlalchemy.Column[datetime.datetime | None][source]
recipients: sqlalchemy.orm.relationship[list[Recipient]][source]
property open_recipients: tuple[Recipient, Ellipsis][source]
show_news_as_tiles: onegov.core.orm.mixins.dict_property[bool][source]
newsletter_categories: onegov.core.orm.mixins.dict_property[list[str] | None][source]
class newsletter.models.Recipient[source]

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

Represents a single recipient.

Recipients may be grouped by any kind of string. Only inside their groups are recipient addresses unique. However, groups are an optional feature and they are not deeply integrated. If you don’t care for group, never use them and the list becomes like a simple list of addresses with no duplicate addresses present.

__tablename__ = 'recipients'[source]
id: sqlalchemy.Column[uuid.UUID][source]
address: sqlalchemy.Column[str][source]
validate_address(key: str, address: str) str[source]
group: sqlalchemy.Column[str | None][source]
newsletters: sqlalchemy.orm.relationship[list[Newsletter]][source]
token: sqlalchemy.Column[str][source]
confirmed: sqlalchemy.Column[bool][source]
subscribed_categories: onegov.core.orm.mixins.dict_property[list[str] | None][source]
daily_newsletter: sqlalchemy.Column[bool][source]
property __table_args__: tuple[sqlalchemy.Index, Ellipsis][source]
property subscription: Subscription[source]
property is_inactive: bool[source]

Checks if the recipient’s email address is marked as inactive.

Returns:

bool: True if the email address is marked as inactive, False otherwise.

mark_inactive() None[source]

Marks the recipient’s email address as inactive.

This method sets the ‘inactive’ flag in the recipient’s metadata to True. It is typically used when a bounce event causes the email address to be deactivated by Postmark.

reactivate() None[source]

Marks a previously inactive recipient as active again.

class newsletter.models.Subscription(recipient: Recipient, token: str)[source]

Adds subscription management to a recipient.

recipient[source]
token[source]
property recipient_id: uuid.UUID[source]
confirm() bool[source]
unsubscribe() bool[source]