Skip to content

Improve management of Mail templates #91

@staydecent

Description

@staydecent

We want to avoid calling Mail templates that don't exist in production. We also want to avoid calling mail templates with the wrong or missing data.

The first part is to create a registry of Mail templates. This way, we have an explicit list of the templates we expect to exist in production.

Possible ways to define the registry:

  1. In settings
MAIL_REGISTRY = {
    'Forgot Password': {
        'email': 'example@example.com',
        'reset_url': 'example.com/forgot/1234/12'
    },
    'Confirm Email': {
        'email': 'example@example.com',
        'confirm_url': 'example.com/confirm/1234/12'
    },
    ...
}
  1. With decorators
@mail('Forgot Password')
def forgot_password(email, reset_url):
    ...

Open to other ideas for managing the registry as well.

Beyond just having a registry, it would be ideal to automate syncing templates from local development to the staging and productions servers. Iterating on a solution that @adriaanwm has implemented before:

  • We define the staging and production API URLs in settings.
  • We implement an api endpoint to check/sync templates.
  • On Mail model save, we check those endpoints to sync our template from local to production (if it meets data requirements etc.)

This is just one idea to automate syncing of templates from local development to the staging and production servers. Ideas are welcomed!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions