Reference¶
Models¶
- class mailinglist.models.GlobalDeny(*args, **kwargs)¶
Users with instances here will not receive mailing list messages.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class mailinglist.models.MailingList(*args, **kwargs)¶
The fundamental model for sending messages. A mailing list can be subscribed to by users and is required for composing (and therefore sending) messages
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- property published_messages¶
All messages that have been published to this mailing list prior to now
- property sender_tag¶
Mailing list sender formatted in the standard way for email addresses:: “FirstName LastName” <email>
- class mailinglist.models.Message(*args, **kwargs)¶
The messages which will be sent to subscribed users. Comprised of
MessagePartandMessageAttachmentinstances.- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class mailinglist.models.MessageAttachment(*args, **kwargs)¶
The file content of a
Message- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- save(**kwargs)¶
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class mailinglist.models.MessagePart(*args, **kwargs)¶
The text content of a
Message.- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class mailinglist.models.Sending(*args, **kwargs)¶
Tracks the sending of each
Submissionto each individualSubscription. Provided for audit, as well as to allow interruped send jobs to be resumed without double-sending to any users.- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class mailinglist.models.Submission(*args, **kwargs)¶
The means by which
Messageinstances are published and sent.- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class mailinglist.models.Subscription(*args, **kwargs)¶
The means by which a user subscribes to receive mailing list messages. Do not create instances of this yourself, use the methods in ``mailinglist.services.SubscriptionService`` for managing subscriptions!
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
Services¶
- class mailinglist.services.MessageService¶
Composes email for sending
- prepare_confirmation_kwargs(*, subscription: Subscription, template_set: TemplateSet)¶
Composes and structures outgoing message data for confirmation email
- prepare_message_kwargs(*, subscription: Subscription, template_set: TemplateSet, message: Message)¶
Composes and structures outgoing message data for email sending
- class mailinglist.services.SubmissionService¶
Manages send activities for published submissions.
- process_submission(submission: Submission, *, send_count: int = 0)¶
Sends submitted message to each (non-excluded) subscriber, observing rate limits configured in settings.
- process_submissions()¶
Finds all unsent published
Submissioninstances and sends them.
- publish(submission: Submission)¶
Mark a
Submissionfor sending.
- class mailinglist.services.SubscriptionService¶
Manages all subscription and unsubscribe events.
- confirm_subscription(*, token: str)¶
Activates a subscription
- create_user(*, email: str, first_name: str, last_name: str)¶
Creates a “user” for a new subscription. This method calls the same-named method in the hookset to actually perform the action.
- force_subscribe(*, user, mailing_list: MailingList)¶
Creates an active subscription skipping any confirmation email.
- subscribe(*, user, mailing_list: MailingList, force_confirm=False)¶
Creates a subscription and sends the activation email (or just activates it based on settings)
- unsubscribe(*, token: str)¶
Deactivates a subscription
- class mailinglist.services.TemplateSet(*, mailing_list: MailingList = None, action: str = 'message')¶
Represents the templates needed for generating outgoing email.
- render_to_dict(context: dict)¶
Renders each template in the set and arranges the text into a dictionary, requires the context for the specific message and subscription
Forms¶
- class mailinglist.forms.SubscribeForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)¶
Basic subscription details.
- property media¶
Return all media required to render the widgets on this form.
- class mailinglist.forms.SubscriptionForm(*args, user, **kwargs)¶
Dynamically generates a series of checkboxes for each visible mailing list so that users can subscribe at their will. Also includes checkbox for global unsubscribe.
- property media¶
Return all media required to render the widgets on this form.
Views¶
- class mailinglist.views.ArchiveIndexView(**kwargs)¶
Allows user to browse messages published on a mailing list.
- class mailinglist.views.ArchiveView(**kwargs)¶
Allows user to view messages published on a mailing list.
- get_object(**kwargs)¶
Return the object the view is displaying.
Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.
- class mailinglist.views.ArchivesView(**kwargs)¶
Allows user to browse messages published on a mailing list.
- class mailinglist.views.DetailFormView(**kwargs)¶
- get(request, *args, **kwargs)¶
Handle GET requests: instantiate a blank version of the form.
- post(request, *args, **kwargs)¶
Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.
- class mailinglist.views.GlobalDenyView(**kwargs)¶
Allows users to subscrbe to the global deny list.
- get_success_url()¶
Return the URL to redirect to after processing a valid form.
- class mailinglist.views.SubscribeConfirmView(**kwargs)¶
Reachable when user clicks on link in confirmation message, tells user that they are fully subscribed.
- class mailinglist.views.SubscribeSuccessView(**kwargs)¶
Provides user with insight about subscription, namely whether or not they will need to confirm their email address
- get_context_data(**kwargs)¶
Insert the single object into the context dict.
- class mailinglist.views.SubscribeView(**kwargs)¶
Allows users to subscrbe to a mailing list.
- get_success_url()¶
Return the URL to redirect to after processing a valid form.
- class mailinglist.views.SubscriptionView(**kwargs)¶
Allows the user to view what mailing lists they are subscribed to.
- form_class¶
alias of
SubscriptionForm
- form_valid(form)¶
If the form is valid, redirect to the supplied URL.
- get_form_kwargs()¶
Return the keyword arguments for instantiating the form.
- get_success_url()¶
Return the URL to redirect to after processing a valid form.
- class mailinglist.views.UnsubscribeView(**kwargs)¶
Reachable when user clicks unsubscribe link in any sent message. Deactivates user’s subscription to the mailing list and provides link to user’s subscriptions page