From ba2302ae5624b11bdddb838cbb8fc09481bcc1c7 Mon Sep 17 00:00:00 2001 From: medmunds Date: Sun, 20 Apr 2014 12:57:08 -0700 Subject: [PATCH] Subaccounts: Document setting; verify message option overrides global setting --- AUTHORS.txt | 2 ++ djrill/tests/test_mandrill_subaccounts.py | 11 +++++++++++ docs/installation.rst | 22 ++++++++++++++++++++++ docs/usage/sending_mail.rst | 2 ++ 4 files changed, 37 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 411b114..6e29dcf 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -12,3 +12,5 @@ peillis José Padilla Jens Alm Eric Hennings +Michael Hobbs +Sameer Al-Sakran diff --git a/djrill/tests/test_mandrill_subaccounts.py b/djrill/tests/test_mandrill_subaccounts.py index d8c137e..00de13f 100644 --- a/djrill/tests/test_mandrill_subaccounts.py +++ b/djrill/tests/test_mandrill_subaccounts.py @@ -34,3 +34,14 @@ class DjrillMandrillSubaccountTests(DjrillBackendMockAPITestCase): self.assertEqual(len(data['message']['to']), 1) self.assertEqual(data['message']['to'][0]['email'], "to@example.com") self.assertEqual(data['message']['subaccount'], settings.MANDRILL_SUBACCOUNT) + + def test_subaccount_message_overrides_setting(self): + settings.MANDRILL_SUBACCOUNT = "global_setting_subaccount" + message = mail.EmailMessage( + 'Subject here', 'Here is the message', + 'from@example.com', ['to@example.com']) + message.subaccount = "individual_message_subaccount" # should override global setting + message.send() + self.assert_mandrill_called("/messages/send.json") + data = self.get_api_call_data() + self.assertEqual(data['message']['subaccount'], "individual_message_subaccount") diff --git a/docs/installation.rst b/docs/installation.rst index 464fcb7..7f2db83 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -15,6 +15,8 @@ library from Kenneth Reitz. Configuration ------------- +.. setting:: MANDRILL_API_KEY + In your project's :file:`settings.py`: 1. Add :mod:`djrill` to your :setting:`INSTALLED_APPS`:: @@ -40,6 +42,26 @@ Djrill includes optional support for Mandrill webhooks, including inbound email. See the Djrill :ref:`webhooks ` section for configuration details. +Mandrill Subaccounts (Optional) +------------------------------- + +.. setting:: MANDRILL_SUBACCOUNT + +If you are using Mandrill's `subaccounts`_ feature, you can globally set the +subaccount for all messages sent through Djrill:: + + MANDRILL_SUBACCOUNT = "client-347" + +(You can also set or override the :attr:`subaccount` on each individual message, +with :ref:`Mandrill-specific sending options `.) + +.. versionadded:: 1.0 + MANDRILL_SUBACCOUNT global setting + + +.. _subaccounts: http://help.mandrill.com/entries/25523278-What-are-subaccounts- + + Admin (Optional) ---------------- diff --git a/docs/usage/sending_mail.rst b/docs/usage/sending_mail.rst index 789db12..99dd1d6 100644 --- a/docs/usage/sending_mail.rst +++ b/docs/usage/sending_mail.rst @@ -199,6 +199,8 @@ Most of the options from the Mandrill .. attribute:: subaccount ``str``: the ID of one of your subaccounts to use for sending this message. + (The subaccount on an individual message will override any global + :setting:`MANDRILL_SUBACCOUNT` setting.) .. versionadded:: 0.7