Models

The pennyblack core models

class pennyblack.models.newsletter.Newsletter(*args, **kwargs)

A newsletter with subject and content can contain multiple jobs with mails to send

create_snapshot()

Makes a copy of itselve with all the content and returns the copy.

get_default_job()

Tries to get the default job. If no default job exists it creates one. This is only used in workflow newsletters.

is_valid()

Checks if the newsletter is valid. A newsletter needs to have a subject to be valid.

is_workflow()

Returns True if it’s type is a workflow newsletter.

prepare_to_send()

Last hook before the newsletter is sent

Register a new view link Newsletter.register_view_link(‘my_identifier’,view_function)

Searches al links in content sections and replaces them with a link to the link tracking view. It also generates the header_url_replaced which is the same but for the header url.

send(person, group=None)

Sends this newsletter to “person” with optional “group”. This works only with newsletters which are workflow newsletters.

class pennyblack.models.newsletter.NewsletterManager
active()

Filters all active newsletters

get_workflow_newsletter_by_name(name)

Tries to get a newsletter with the given name. First it tries to find one where the language matches the active language, later it tries to find one with the default language and if it doesn’t find one it tries to get any newsletter with the given name before giving up.

massmail()

Filters all newsletter avaiable for massmailing

workflow()

Filters all newsletter avaiable in a workflow eg. signupmail

class pennyblack.models.mail.Mail(*args, **kwargs)

This is a single Mail, it’s part of a Job

bounce()

Is executed if this email is bounced.

get_content(webview=False)

Renders the email content. If webview is True it includes also a html header and doesn’t display the webview link.

get_context()

Returns the context of this email as a dict.

get_email()

Gets the email address. If it has no email address set, it tries to get it from the person object.

get_header_url()

Gets the header url for this email.

get_message()

Returns a email message object

is_valid()

Checks if this Mail is valid by validating the email address.

mark_sent()

Marks the email as beeing sent.

mark_viewed()

Marks the email as beeing viewed and if it’s not already viewed it stores the view date.

on_landing(request)

Is executed every time a user landed on the website after clicking on a link in this email. It tries to execute the on_landing method on the person object and on the group object.

person

Provides a generic relation to any object through content-type/object-id fields.

unsubscribe()

Is executed if the unsubscribe link is clicked.

Link(id, job_id, identifier, link_hash, link_target)

click(mail)

Creates a LinkClick and returns the link target

click_count()

Returns the total click count.

get_target(mail)

gets the link target by evaluating the string using the email content

class pennyblack.models.sender.Sender(*args, **kwargs)

A sender for the from and reply to fields of the newsletter.

check_spf()

Check if sender is authorised by sender policy framework

get_mail()

Checks the inbox of this sender and prcesses the bounced emails

Previous topic

Template

Next topic

Pennyblack 0.3.0 release notes

This Page