Metadata-Version: 2.1
Name: django-solar
Version: 0.0.1
Summary: Django Email Automation
Home-page: https://github.com/Aleksi44/django-solar/
Author: Alexis Le Baron
Author-email: hello@snoweb.fr
License: GPL-3.0
Keywords: django email automation
Platform: linux
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development
Requires-Dist: django (>=3.0.9)

************
Django Solar
************

.. image:: https://img.shields.io/pypi/v/django_solar
    :target: https://pypi.org/project/django_solar/

.. image:: https://img.shields.io/pypi/pyversions/django_solar
    :target: https://pypi.org/project/django_solar/

Django email automation with cron.

Tested with :

- django==3.0.9

Setup
#####

Install with pip :
::

    pip install django_solar


Add django_solar to django apps installed :
::

    INSTALLED_APPS = [
        ...
        'django_solar',
    ]


Set Django email backend :
::

    # Take a look at https://github.com/anymail/django-anymail

    ANYMAIL = {
        "MAILJET_API_KEY": env.str('MAILJET_API_KEY'),
        "MAILJET_SECRET_KEY": env.str('MAILJET_SECRET_KEY'),
    }
    MAILJET_API_KEY = env.str('MAILJET_API_KEY')
    MAILJET_SECRET_KEY = env.str('MAILJET_SECRET_KEY')

    EMAIL_BACKEND = "anymail.backends.mailjet.EmailBackend"
    DEFAULT_FROM_EMAIL = "hello@snoweb.fr"
    SERVER_EMAIL = "hello@snoweb.fr"


Set django_solar context :
::

    DS_CRON_HOUR = 1  # Period of cron in hours
    DS_EVENT_MANAGER = "tests.manager.EventManager"  #  Class manager of events


Set cron command
::

    0 * * * * python manage.py solar




Defines Events
##############

Example of EventManger :
::

    from django_solar import AEventManager, MailTemplate
    from django_solar.models import Mail
    from datetime import datetime


    class EventManager(AEventManager):

        def event_something(self):
            Mail.objects.create(
                mail='test@exemple.com',  #  Receiver
                send_at=datetime.now(),  #  Datetime send
                html=MailTemplate.get(key='test'),  #  HTML of email
                subject="Test Django Solar"  #  Subject of email
            )


