|
1 | | -"""See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/""" |
| 1 | +"""See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/""" |
2 | 2 |
|
3 | 3 | import logging |
| 4 | +from email.utils import formataddr, getaddresses |
4 | 5 |
|
5 | | -from email.utils import getaddresses |
6 | | - |
7 | | -from .base import * # noqa |
8 | 6 | import sentry_sdk |
| 7 | +# from sentry_sdk.integrations.celery import CeleryIntegration |
9 | 8 | from sentry_sdk.integrations.django import DjangoIntegration |
10 | 9 | from sentry_sdk.integrations.logging import LoggingIntegration |
| 10 | +from sentry_sdk.integrations.redis import RedisIntegration |
| 11 | + |
| 12 | +from .base import * # noqa |
11 | 13 |
|
12 | 14 | DEBUG = False # just to make sure! |
13 | 15 |
|
|
53 | 55 | # "COMPRESSOR": "django_redis.compressors.zlib.ZlibCompressor", |
54 | 56 | "COMPRESSOR": "django_redis.compressors.lz4.Lz4Compressor", |
55 | 57 | }, |
56 | | - } |
| 58 | + }, |
| 59 | + "renditions": { |
| 60 | + "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", |
| 61 | + "LOCATION": env("MEMCACHED_URL"), # noqa F405 |
| 62 | + "TIMEOUT": 600, |
| 63 | + "OPTIONS": {"MAX_ENTRIES": 1000}, |
| 64 | + }, |
57 | 65 | } |
58 | 66 | SESSION_ENGINE = "django.contrib.sessions.backends.cache" |
59 | 67 | SESSION_CACHE_ALIAS = "default" |
60 | 68 |
|
61 | 69 | WAGTAILFRONTENDCACHE = { |
62 | 70 | "cloudflare": { |
63 | 71 | "BACKEND": "wagtail.contrib.frontend_cache.backends.CloudflareBackend", |
64 | | - "EMAIL": env("CLOUDFLARE_EMAIL_ADDRESS"), # noqa F405 |
65 | | - "TOKEN": env("CLOUDFLARE_API_TOKEN"), # noqa F405 |
| 72 | + "BEARER_TOKEN": env("CLOUDFLARE_BEARER_TOKEN"), # noqa F405 |
66 | 73 | "ZONEID": env("CLOUDFLARE_DOMAIN_ZONE_ID"), # noqa F405 |
67 | 74 | }, |
68 | 75 | } |
|
75 | 82 | SESSION_COOKIE_SECURE = True |
76 | 83 | CSRF_COOKIE_SECURE = True |
77 | 84 |
|
78 | | -# setup email backend |
79 | | -EMAIL_BACKEND = "sendgrid_backend.SendgridBackend" |
80 | | -SENDGRID_API_KEY = env("SENDGRID_API_KEY") # noqa F405 |
| 85 | +# setup email backend via Anymail |
| 86 | +# ------------------------------------------------------------------------------ |
| 87 | +# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail |
| 88 | +INSTALLED_APPS += ["anymail"] # noqa F405 |
| 89 | +# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend |
| 90 | +# https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference |
| 91 | +# https://anymail.readthedocs.io/en/stable/esps/sendgrid/ |
| 92 | +EMAIL_BACKEND = "anymail.backends.sendgrid.EmailBackend" |
| 93 | +ANYMAIL = { |
| 94 | + "SENDGRID_API_KEY": env("SENDGRID_API_KEY"), # noqa F405 |
| 95 | + "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID"), # noqa F405 |
| 96 | + "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT"), # noqa F405 |
| 97 | + "SENDGRID_API_URL": env( # noqa F405 |
| 98 | + "SENDGRID_API_URL", default="https://api.sendgrid.com/v3/" |
| 99 | + ), |
| 100 | +} |
81 | 101 |
|
82 | 102 | if len(getaddresses([env("EMAIL_RECIPIENTS")])) == 1: # noqa F405 |
83 | 103 | LIST_OF_EMAIL_RECIPIENTS.append( # noqa F405 |
84 | | - getaddresses([env("EMAIL_RECIPIENTS")])[0] # noqa F405 |
| 104 | + formataddr(getaddresses([env("EMAIL_RECIPIENTS")])[0]) # noqa F405 |
85 | 105 | ) |
86 | 106 | else: |
87 | | - LIST_OF_EMAIL_RECIPIENTS += getaddresses([env("EMAIL_RECIPIENTS")]) # noqa F405 |
| 107 | + for email_address in getaddresses([env("EMAIL_RECIPIENTS")]): # noqa F405 |
| 108 | + LIST_OF_EMAIL_RECIPIENTS += formataddr(email_address) # noqa F405 |
88 | 109 |
|
89 | | -if len(getaddresses([env("DEFAULT_FROM_EMAIL")])) == 1: # noqa F405 |
90 | | - DEFAULT_FROM_EMAIL = getaddresses([env("DEFAULT_FROM_EMAIL")])[0] # noqa F405 |
91 | | -else: |
92 | | - DEFAULT_FROM_EMAIL = getaddresses([env("DEFAULT_FROM_EMAIL")]) # noqa F405 |
| 110 | +email_address = getaddresses([env("DEFAULT_FROM_EMAIL")])[0] # noqa F405 |
| 111 | +DEFAULT_FROM_EMAIL = formataddr(email_address) |
93 | 112 |
|
94 | | -# try: |
95 | | -# from .local import * |
96 | | -# except ImportError: |
97 | | -# pass |
| 113 | +# https://docs.djangoproject.com/en/dev/ref/settings/#server-email |
| 114 | +SERVER_EMAIL = env("DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL) # noqa F405 |
98 | 115 |
|
99 | 116 | # enable SSL flag, if the data exchange needs to be secure. |
100 | 117 | # Not needed for small apps |
|
148 | 165 | level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs |
149 | 166 | event_level=logging.ERROR, # Send errors as events |
150 | 167 | ) |
151 | | -integrations = [sentry_logging, DjangoIntegration()] |
| 168 | +integrations = [ |
| 169 | + sentry_logging, |
| 170 | + DjangoIntegration(), |
| 171 | + # CeleryIntegration(), |
| 172 | + RedisIntegration(), |
| 173 | +] |
152 | 174 | sentry_sdk.init( |
153 | 175 | dsn=SENTRY_DSN, |
154 | 176 | integrations=integrations, |
155 | 177 | environment=env("SENTRY_ENVIRONMENT", default="production"), # noqa F405 |
156 | 178 | traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0.0), # noqa F405 |
| 179 | + # If you wish to associate users to errors (assuming you are using |
| 180 | + # django.contrib.auth) you may enable sending PII data. |
| 181 | + send_default_pii=True, |
157 | 182 | ) |
0 commit comments