<commit_before>tt_dailyemailblast
==================
Simple application for handling our daily emails to partners.

.. note:: This could be a *lot* more complex and do all manner of
   awesome stuff like auto-generating the body based on stories that
   are in the CMS.  That's so much bigger than we need right now.

 This is definitely in the "works for what we need" camp, feel free
 to use it as an example of sending emails out using Celery, but
 probably not something to actually use.


Installation & Configuration
----------------------------
You can install this using `pip`_ like this::

    pip install tt_dailyemailblast

Once installed, you need to add it to your ``INSTALLED_APPS``.  You can do that
however you like or you can copy-and-paste this in after your
``INSTALLED_APPS`` are defined::

    INSTALLED_APPS += ['tt_dailyemailblast', ]

The next setting to configure is the **from** email address::

    TT_DAILYEMAILBLAST_FROMEMAIL = '<EMAIL>'

``tt_dailyemailblast`` can accept any backend to suit your integration needs.

To send an email, you'll need a template for the **body**.
``tt_dailyemailblast`` will look for templates in your project in this order:

1. ``tt_dailyemailblast/<blast_type>/<recipient_list>/<recipient>.html``
2. ``tt_dailyemailblast/<blast_type>/<recipient_list>.html``
3. ``tt_dailyemailblast/<blast_type>.html``

If you need special context generated in that template, you can specify that
with the context backend setting::

    TT_DAILYEMAILBLAST_CONTEXT = 'tt.dailyemailblast.context_backend'

Finally, to actually send emails, ``tt_dailyemailblast`` will use the sync
backend by default. You can explicitly specify that with the setting::

    from tt_dailyemailblast.settings.sync import *

To use async Celery workers to send, add::

    from tt_dailyemailblast.settings.async import *


Usage
-----
*TODO*


Example
-------
All of the usage is outlined, along with tests inside the ``example``
directory.  See that directory for more information on how to run the tests and
example project.

.. _pip: http://www.pip-installer.org/en/latest/
<commit_msg>add usage section<commit_after>tt_dailyemailblast
==================
Simple application for handling our daily emails to partners.

.. note:: This could be a *lot* more complex and do all manner of
   awesome stuff like auto-generating the body based on stories that
   are in the CMS.  That's so much bigger than we need right now.

 This is definitely in the "works for what we need" camp, feel free
 to use it as an example of sending emails out using Celery, but
 probably not something to actually use.


Installation & Configuration
----------------------------
You can install this using `pip`_ like this::

    pip install tt_dailyemailblast

Once installed, you need to add it to your ``INSTALLED_APPS``.  You can do that
however you like or you can copy-and-paste this in after your
``INSTALLED_APPS`` are defined::

    INSTALLED_APPS += ['tt_dailyemailblast', ]

The next setting to configure is the **from** email address::

    TT_DAILYEMAILBLAST_FROMEMAIL = '<EMAIL>'

``tt_dailyemailblast`` can accept any backend to suit your integration needs.

To send an email, you'll need a template for the **body**.
``tt_dailyemailblast`` will look for templates in your project in this order:

1. ``tt_dailyemailblast/<blast_type>/<recipient_list>/<recipient>.html``
2. ``tt_dailyemailblast/<blast_type>/<recipient_list>.html``
3. ``tt_dailyemailblast/<blast_type>.html``

If you need special context generated in that template, you can specify that
with the context backend setting::

    TT_DAILYEMAILBLAST_CONTEXT = 'tt.dailyemailblast.context_backend'

Finally, to actually send emails, ``tt_dailyemailblast`` will use the sync
backend by default. You can explicitly specify that with the setting::

    from tt_dailyemailblast.settings.sync import *

To use async Celery workers to send, add::

    from tt_dailyemailblast.settings.async import *


Usage
-----

Templates
~~~~~~~~~
Your templates should render to html. The context will get these variables:

* ``{{ blast }}`` - The ``DailyEmailBlast`` object.
* ``{{ recipient }}`` - The ``Recipient`` object.
* ``{{ recipient_list }}`` - The ``RecipientList`` object.

Context Backend
~~~~~~~~~~~~~~~
Your context backend should take the arguments:

* ``blast``
* ``recipient``
* ``recipient_list``

And should be patterened after this basic example::

    from tt_dailyemailblast.context_backends import basic

    def context_backend(blast, recipient, recipient_list):
        context = basic(blast, recipient, recipient_list)
        # modify context
        return context


Example
-------
All of the usage is outlined, along with tests inside the ``example``
directory.  See that directory for more information on how to run the tests and
example project.

.. _pip: http://www.pip-installer.org/en/latest/

{'fraction_non_alphanumeric': 0.10783711888684265, 'fraction_numerical': 0.0012277470841006752, 'mean_word_length': 4.107628004179729, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1583413', 'n_tokens_mistral': 1448, 'n_tokens_neox': 1322, 'n_words': 580}