GitHub project link unavailable.
This project aims to automate sending repetitive emails, for example:
- reminders about submitting a workshop's website and slug
- thank-you emails for the instructors and hosts after workshop had run
- reminders to recruit helpers
All these emails used to be sent by hand, now they are automatically sent on a specific time before/after some date. For example, "Recruit Helpers" email is sent 21 days before event's start date, but only if there are no helpers on the event.
At the core of automated emails there are:
- Redis database for keeping list of scheduled actions ordered by scheduled time
- Python RQ library
Basic principle of work:
- Every scheduled action is an instance of a subclass of
__call__()method for sending emails.
- When specific conditions are met, for example an instructor is added to the event, an instance of specific corresponding action is created and set up. Using RQ library that action is then scheduled to run at specific time.
- RQ library serializes (pickles) that action and puts it in Redis.
- A specific RQ worker (application running on a server) reads from the Redis looking for actions which should be run.
- Once the worker retrieves an action to be run, it deserializes (unpickles) it and
__call__()method, which sends an email.
Implementation of new actions
There's a few steps that should be taken when implementing a new action.
- Add new action to
get_additional_contextfor defining context passed to email's template
- implement static
check()method for determining if the action conditions are met or not
- Define template corresponding with that action, add it to
autoemails/models.pywith new action.
- Provide extensive tests for the action itself (see
- In views supporting changes that might trigger the action, use
ActionManageMixin.remove()along with action's
check()method (defined in step 1 above) to schedule or unschedule action email.
Scheduled automated emails can be previewed in Django Admin. There are options to reschedule, re-try if emails failed, and more.
Custom templates and views were implemented to handle this admin panel.