Reference

For now, this documentation is automatically generated from the source code.

Models

_images/graph_models.png
class Newsletter(id, title, slug, email, sender, visible, send_html)

Bases: django.db.models.base.Model

get_templates(action)

Return a subject, text, HTML tuple with e-mail templates for a particular action. Returns a tuple with subject, text and e-mail template.

class Subscription(id, user, name_field, email_field, ip, newsletter, create_date, activation_code, subscribed, subscribe_date, unsubscribed, unsubscribe_date)

Bases: django.db.models.base.Model

update(action)

Update subscription according to requested action: subscribe/unsubscribe/update/, then save the changes.

save(*args, **kwargs)

Perform some basic validation and state maintenance of Subscription.

TODO: Move this code to a more suitable place (i.e. clean()) and cleanup the code. Refer to comment below and https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.clean

class Article(*args, **kwargs)

Bases: django.db.models.base.Model

An Article within a Message which will be send through a Submission.

class Message(*args, **kwargs)

Bases: django.db.models.base.Model

Message as sent through a Submission.

get_next_article_sortorder()

Get next available sortorder for Article.

class Submission(*args, **kwargs)

Bases: django.db.models.base.Model

Submission represents a particular Message as it is being submitted to a list of Subscribers. This is where actual queueing and submission happen.

save()

Set the newsletter from associated message upon saving.

Forms

class NewsletterForm(*args, **kwargs)

Bases: django.forms.models.ModelForm

This is the base class for all forms managing subscriptions.

class SubscribeRequestForm(*args, **kwargs)

Bases: newsletter.forms.NewsletterForm

Request subscription to the newsletter. Will result in an activation email being sent with a link where one can edit, confirm and activate one’s subscription.

class UpdateRequestForm(*args, **kwargs)

Bases: newsletter.forms.NewsletterForm

Request updating or activating subscription. Will result in an activation email being sent.

class UnsubscribeRequestForm(*args, **kwargs)

Bases: newsletter.forms.UpdateRequestForm

Similar to previous form but checks if we have not already been unsubscribed.

class UpdateForm(*args, **kwargs)

Bases: newsletter.forms.NewsletterForm

This form allows one to actually update to or unsubscribe from the newsletter. To do this, a correct activation code is required.

class UserUpdateForm(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)

Bases: django.forms.models.ModelForm

Form for updating subscription information/unsubscribing as a logged-in user.

Views

is_authenticated(user)
class NewsletterViewBase

Bases: object

Base class for newsletter views.

queryset = <QuerySet []>
allow_empty = False
slug_url_kwarg = 'newsletter_slug'
class NewsletterDetailView(**kwargs)

Bases: newsletter.views.NewsletterViewBase, django.views.generic.detail.DetailView

class NewsletterListView(**kwargs)

Bases: newsletter.views.NewsletterViewBase, django.views.generic.list.ListView

List available newsletters and generate a formset for (un)subscription for authenticated users.

post(request, **kwargs)

Allow post requests.

get_context_data(**kwargs)
get_formset()

Return a formset with newsletters for logged in users, or None.

class ProcessUrlDataMixin

Bases: object

Mixin providing the ability to process args and kwargs from url before dispatching request.

process_url_data(*args, **kwargs)

Subclasses should put url data processing in this method.

dispatch(*args, **kwargs)
class NewsletterMixin

Bases: newsletter.views.ProcessUrlDataMixin

Mixin retrieving newsletter based on newsletter_slug from url and adding it to context and form kwargs.

process_url_data(*args, **kwargs)

Get newsletter based on newsletter_slug from url and add it to instance attributes.

get_form_kwargs()

Add newsletter to form kwargs.

get_context_data(**kwargs)

Add newsletter to context.

class ActionMixin

Bases: newsletter.views.ProcessUrlDataMixin

Mixin retrieving action from url and adding it to context.

action = None
process_url_data(*args, **kwargs)

Add action from url to instance attributes if not already set.

get_context_data(**kwargs)

Add action to context.

get_template_names()

Return list of template names for proper action.

class ActionTemplateView(**kwargs)

Bases: newsletter.views.NewsletterMixin, newsletter.views.ActionMixin, django.views.generic.base.TemplateView

View that renders a template for proper action, with newsletter and action in context.

class ActionFormView(**kwargs)

Bases: newsletter.views.NewsletterMixin, newsletter.views.ActionMixin, django.views.generic.edit.FormView

FormView with newsletter and action support.

get_url_from_viewname(viewname)

Return url for given viename and associated with this view newsletter and action.

class ActionUserView(**kwargs)

Bases: newsletter.views.ActionTemplateView

Base class for subscribe and unsubscribe user views.

template_name = 'newsletter/subscription_%(action)s_user.html'
process_url_data(*args, **kwargs)

Add confirm to instance attributes.

post(request, *args, **kwargs)
dispatch(*args, **kwargs)
class SubscribeUserView(**kwargs)

Bases: newsletter.views.ActionUserView

action = 'subscribe'
get(request, *args, **kwargs)
class UnsubscribeUserView(**kwargs)

Bases: newsletter.views.ActionUserView

action = 'unsubscribe'
get(request, *args, **kwargs)
class ActionRequestView(**kwargs)

Bases: newsletter.views.ActionFormView

Base class for subscribe, unsubscribe and update request views.

template_name = 'newsletter/subscription_%(action)s.html'
process_url_data(*args, **kwargs)

Add error to instance attributes.

get_context_data(**kwargs)

Add error to context.

get_subscription(form)

Return subscription for the current request.

no_email_confirm(form)

Subscribe/unsubscribe user and redirect to action activated page.

get_success_url()
form_valid(form)
class SubscribeRequestView(**kwargs)

Bases: newsletter.views.ActionRequestView

action = 'subscribe'
form_class

alias of SubscribeRequestForm

confirm = False
get_form_kwargs()

Add ip to form kwargs for submitted forms.

get_subscription(form)
dispatch(request, *args, **kwargs)
class UnsubscribeRequestView(**kwargs)

Bases: newsletter.views.ActionRequestView

action = 'unsubscribe'
form_class

alias of UnsubscribeRequestForm

confirm = False
dispatch(request, *args, **kwargs)
class UpdateRequestView(**kwargs)

Bases: newsletter.views.ActionRequestView

action = 'update'
form_class

alias of UpdateRequestForm

no_email_confirm(form)

Redirect to update subscription view.

class UpdateSubscriptionView(**kwargs)

Bases: newsletter.views.ActionFormView

form_class

alias of UpdateForm

template_name = 'newsletter/subscription_activate.html'
process_url_data(*args, **kwargs)

Add email, subscription and activation_code to instance attributes.

get_initial()

Returns the initial data to use for forms on this view.

get_form_kwargs()

Add instance to form kwargs.

get_success_url()
form_valid(form)

Get our instance, but do not save yet.

class SubmissionViewBase

Bases: newsletter.views.NewsletterMixin

Base class for submission archive views.

date_field = 'publish_date'
allow_empty = True
queryset = <QuerySet []>
slug_field = 'message__slug'
year_format = '%Y'
month_format = '%m'
day_format = '%d'
process_url_data(*args, **kwargs)

Use only visible newsletters.

get_queryset()

Filter out submissions for current newsletter.

class SubmissionArchiveIndexView(**kwargs)

Bases: newsletter.views.SubmissionViewBase, django.views.generic.dates.ArchiveIndexView

class SubmissionArchiveDetailView(**kwargs)

Bases: newsletter.views.SubmissionViewBase, django.views.generic.dates.DateDetailView

get_context_data(**kwargs)

Make sure the actual message is available.

get_template()

Get the message template for the current newsletter.

render_to_response(context, **response_kwargs)

Return a simplified response; the template should be rendered without any context. Use a SimpleTemplateResponse as a RequestContext should not be used.