Skip to content

Commit 0aae81b

Browse files
Linda PengLinda Peng
Linda Peng
authored and
Linda Peng
committed
1 parent 046a1c4 commit 0aae81b

File tree

1 file changed

+1
-103
lines changed

1 file changed

+1
-103
lines changed

project/config/settings/production.py

+1-103
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import logging
22

3-
import sentry_sdk
4-
5-
from sentry_sdk.integrations.django import DjangoIntegration
6-
from sentry_sdk.integrations.logging import LoggingIntegration
7-
from sentry_sdk.integrations.celery import CeleryIntegration
8-
9-
103
from .base import * # noqa
114
from .base import env
125

@@ -15,29 +8,14 @@
158
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
169
SECRET_KEY = env("DJANGO_SECRET_KEY")
1710
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
18-
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["django.codebuddies.org"])
11+
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS")
1912

2013
# DATABASES
2114
# ------------------------------------------------------------------------------
2215
DATABASES["default"] = env.db("DATABASE_URL") # noqa F405
2316
DATABASES["default"]["ATOMIC_REQUESTS"] = True # noqa F405
2417
DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60) # noqa F405
2518

26-
# CACHES
27-
# ------------------------------------------------------------------------------
28-
CACHES = {
29-
"default": {
30-
"BACKEND": "django_redis.cache.RedisCache",
31-
"LOCATION": env("REDIS_URL"),
32-
"OPTIONS": {
33-
"CLIENT_CLASS": "django_redis.client.DefaultClient",
34-
# Mimicing memcache behavior.
35-
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
36-
"IGNORE_EXCEPTIONS": True,
37-
},
38-
}
39-
}
40-
4119
# SECURITY
4220
# ------------------------------------------------------------------------------
4321
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
@@ -63,53 +41,6 @@
6341
"DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True
6442
)
6543

66-
# STORAGES
67-
# ------------------------------------------------------------------------------
68-
# https://django-storages.readthedocs.io/en/latest/#installation
69-
INSTALLED_APPS += ["storages"] # noqa F405
70-
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
71-
AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID")
72-
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
73-
AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY")
74-
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
75-
AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME")
76-
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
77-
AWS_QUERYSTRING_AUTH = False
78-
# DO NOT change these unless you know what you're doing.
79-
_AWS_EXPIRY = 60 * 60 * 24 * 7
80-
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
81-
AWS_S3_OBJECT_PARAMETERS = {
82-
"CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate"
83-
}
84-
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
85-
AWS_DEFAULT_ACL = None
86-
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
87-
AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None)
88-
# STATIC
89-
# ------------------------
90-
STATICFILES_STORAGE = "config.settings.production.StaticRootS3Boto3Storage"
91-
STATIC_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/static/"
92-
# MEDIA
93-
# ------------------------------------------------------------------------------
94-
# region http://stackoverflow.com/questions/10390244/
95-
# Full-fledge class: https://stackoverflow.com/a/18046120/104731
96-
from storages.backends.s3boto3 import S3Boto3Storage # noqa E402
97-
98-
99-
class StaticRootS3Boto3Storage(S3Boto3Storage):
100-
location = "static"
101-
default_acl = "public-read"
102-
103-
104-
class MediaRootS3Boto3Storage(S3Boto3Storage):
105-
location = "media"
106-
file_overwrite = False
107-
108-
109-
# endregion
110-
DEFAULT_FILE_STORAGE = "config.settings.production.MediaRootS3Boto3Storage"
111-
MEDIA_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/media/"
112-
11344
# TEMPLATES
11445
# ------------------------------------------------------------------------------
11546
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
@@ -141,24 +72,6 @@ class MediaRootS3Boto3Storage(S3Boto3Storage):
14172
# Django Admin URL regex.
14273
ADMIN_URL = env("DJANGO_ADMIN_URL")
14374

144-
# Anymail (Mailgun)
145-
# ------------------------------------------------------------------------------
146-
# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail
147-
INSTALLED_APPS += ["anymail"] # noqa F405
148-
EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
149-
# https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference
150-
ANYMAIL = {
151-
"MAILGUN_API_KEY": env("MAILGUN_API_KEY"),
152-
"MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN"),
153-
"MAILGUN_API_URL": env("MAILGUN_API_URL", default="https://api.mailgun.net/v3"),
154-
}
155-
156-
# Collectfast
157-
# ------------------------------------------------------------------------------
158-
# https://github.com/antonagestam/collectfast#installation
159-
INSTALLED_APPS = ["collectfast"] + INSTALLED_APPS # noqa F405
160-
AWS_PRELOAD_METADATA = True
161-
16275
# LOGGING
16376
# ------------------------------------------------------------------------------
16477
# https://docs.djangoproject.com/en/dev/ref/settings/#logging
@@ -189,7 +102,6 @@ class MediaRootS3Boto3Storage(S3Boto3Storage):
189102
"propagate": False,
190103
},
191104
# Errors logged by the SDK itself
192-
"sentry_sdk": {"level": "ERROR", "handlers": ["console"], "propagate": False},
193105
"django.security.DisallowedHost": {
194106
"level": "ERROR",
195107
"handlers": ["console"],
@@ -198,19 +110,5 @@ class MediaRootS3Boto3Storage(S3Boto3Storage):
198110
},
199111
}
200112

201-
# Sentry
202-
# ------------------------------------------------------------------------------
203-
SENTRY_DSN = env("SENTRY_DSN")
204-
SENTRY_LOG_LEVEL = env.int("DJANGO_SENTRY_LOG_LEVEL", logging.INFO)
205-
206-
sentry_logging = LoggingIntegration(
207-
level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
208-
event_level=logging.ERROR, # Send errors as events
209-
)
210-
sentry_sdk.init(
211-
dsn=SENTRY_DSN,
212-
integrations=[sentry_logging, DjangoIntegration(), CeleryIntegration()],
213-
)
214-
215113
# Your stuff...
216114
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)