Skip to content
Snippets Groups Projects
Commit aa9a2b3e authored by florimondmanca's avatar florimondmanca
Browse files

add system check for SENDGRID_API_KEY setting

parent 8d537690
No related branches found
No related tags found
No related merge requests found
......@@ -6,3 +6,4 @@ class MailsConfig(AppConfig):
def ready(self):
from . import signals # noqa
from . import checks # noqa
"""Mails app system checks."""
from django.conf import settings
from django.core.checks import Warning, register
@register()
def check_sendgrid_api_key_is_set(app_configs, **kwargs):
errors = []
if getattr(settings, 'SENDGRID_API_KEY', None) is None:
errors.append(
Warning(
'SENDGRID_API_KEY is not set, sending emails will fail',
obj=settings,
id='mails.W001',
)
)
return errors
"""Mails app settings."""
from django.conf import settings
import warnings
NOTIFICATIONS_ADDRESS = getattr(settings, 'MAILS_NOTIFICATIONS_ADDRESS')
ENABLED = getattr(settings, 'MAILS_ENABLED')
RAISE_EXCEPTIONS = getattr(settings, 'MAILS_RAISE_EXCEPTIONS')
if getattr(settings, 'SENDGRID_API_KEY', None) is None:
warnings.warn('SENDGRID_API_KEY is not set, sending emails will fail')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment