OneGov Newsletter API

Models

class onegov.newsletter.models.Newsletter(**kwargs)[source]

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.

property es_public

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

the name of the newsletter, derived from the title

title

the title of the newsletter

lead

the optional lead or editorial of the newsletter

html

the content of the newsletter in html, this is not just the partial content, but the actual, fully rendered html content.

sent

null if not sent yet, otherwise the date this newsletter was first sent

scheduled

time the newsletter is scheduled to be sent (in UTC)

recipients

the recipients of this newsletter, meant in part as a tracking feature to answer the question “who got which newsletters?” - for this to work the user of onegov.newsletter has to make sure that sent out newsletters can’t have actual recipients removed from them. onegov.newsletter does not make any guarantees here

class onegov.newsletter.models.Recipient(**kwargs)[source]

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.

id

the id of the recipient, used in the url

address

the email address of the recipient, unique per group

group

the recipient group, a freely choosable string - may be null

newsletters

the newsletters that this recipient received

token

this token is used for confirm and unsubscribe

confirmed

when recipients are added, they are unconfirmed. At this point they get one e-mail with a confirmation link. If they ignore said e-mail they should not get another one.

class onegov.newsletter.models.Subscription(recipient, token)[source]

Adds subscription management to a recipient.

Collection

Errors

exception onegov.newsletter.errors.NewsletterException[source]
exception onegov.newsletter.errors.AlreadyExistsError[source]

Raised if a newsletter exists already.