diff options
| author | 2021-10-17 13:41:51 +0100 | |
|---|---|---|
| committer | 2021-10-17 13:41:51 +0100 | |
| commit | f5ab651b1f8e2dc9f498198087750d4c38010320 (patch) | |
| tree | d101820efaa59f066e37d3aa4d6908663498a1ba /pydis_site/settings.py | |
| parent | Direct appeals to the appeals server (diff) | |
| parent | Merge pull request #613 from python-discord/mbaruh-patch-1 (diff) | |
Merge branch 'main' into new-ban-appeals-process
Diffstat (limited to 'pydis_site/settings.py')
| -rw-r--r-- | pydis_site/settings.py | 45 | 
1 files changed, 21 insertions, 24 deletions
| diff --git a/pydis_site/settings.py b/pydis_site/settings.py index d2cd8698..d38c298b 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -25,7 +25,8 @@ from pydis_site.constants import GIT_SHA  env = environ.Env(      DEBUG=(bool, False),      SITE_DSN=(str, ""), -    BUILDING_DOCKER=(bool, False) +    BUILDING_DOCKER=(bool, False), +    STATIC_BUILD=(bool, False),  )  sentry_sdk.init( @@ -55,22 +56,24 @@ else:      ALLOWED_HOSTS = env.list(          'ALLOWED_HOSTS',          default=[ +            'www.pythondiscord.com',              'pythondiscord.com', -            'admin.pythondiscord.com', -            'api.pythondiscord.com', -            'staff.pythondiscord.com', -            'pydis-api.default.svc.cluster.local',              gethostname(), -            gethostbyname(gethostname()) -        ] +            gethostbyname(gethostname()), +            'site.default.svc.cluster.local', +        ],      )      SECRET_KEY = env('SECRET_KEY')  # Application definition -INSTALLED_APPS = [ +NON_STATIC_APPS = [      'pydis_site.apps.api', -    'pydis_site.apps.home',      'pydis_site.apps.staff', +] if not env("STATIC_BUILD") else [] + +INSTALLED_APPS = [ +    *NON_STATIC_APPS, +    'pydis_site.apps.home',      'pydis_site.apps.resources',      'pydis_site.apps.content',      'pydis_site.apps.events', @@ -84,20 +87,24 @@ INSTALLED_APPS = [      'django.contrib.sites',      'django.contrib.staticfiles', -    'django_hosts',      'django_filters',      'django_simple_bulma',      'rest_framework',      'rest_framework.authtoken', + +    'django_distill',  ]  if not env("BUILDING_DOCKER"):      INSTALLED_APPS.append("django_prometheus") +NON_STATIC_MIDDLEWARE = [ +    'django_prometheus.middleware.PrometheusBeforeMiddleware', +] if not env("STATIC_BUILD") else [] +  # Ensure that Prometheus middlewares are first and last here.  MIDDLEWARE = [ -    'django_prometheus.middleware.PrometheusBeforeMiddleware', -    'django_hosts.middleware.HostsRequestMiddleware', +    *NON_STATIC_MIDDLEWARE,      'django.middleware.security.SecurityMiddleware',      'whitenoise.middleware.WhiteNoiseMiddleware', @@ -108,7 +115,6 @@ MIDDLEWARE = [      'django.contrib.messages.middleware.MessageMiddleware',      'django.middleware.clickjacking.XFrameOptionsMiddleware', -    'django_hosts.middleware.HostsResponseMiddleware',      'django_prometheus.middleware.PrometheusAfterMiddleware'  ] @@ -120,10 +126,6 @@ TEMPLATES = [          'DIRS': [os.path.join(BASE_DIR, 'pydis_site', 'templates')],          'APP_DIRS': True,          'OPTIONS': { -            'builtins': [ -                'django_hosts.templatetags.hosts_override', -            ], -              'context_processors': [                  'django.template.context_processors.debug',                  'django.template.context_processors.request', @@ -143,7 +145,7 @@ WSGI_APPLICATION = 'pydis_site.wsgi.application'  DATABASES = {      'default': env.db(),      'metricity': env.db('METRICITY_DB_URL'), -} +} if not env("STATIC_BUILD") else {}  # Password validation  # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators @@ -185,11 +187,6 @@ STATICFILES_FINDERS = [      'django_simple_bulma.finders.SimpleBulmaFinder',  ] -# django-hosts -# https://django-hosts.readthedocs.io/en/latest/ -ROOT_HOSTCONF = 'pydis_site.hosts' -DEFAULT_HOST = 'home' -  if DEBUG:      PARENT_HOST = env('PARENT_HOST', default='pythondiscord.local:8000') @@ -201,7 +198,7 @@ else:      PARENT_HOST = env('PARENT_HOST', default='pythondiscord.com')  # Django REST framework -# http://www.django-rest-framework.org +# https://www.django-rest-framework.org  REST_FRAMEWORK = {      'DEFAULT_AUTHENTICATION_CLASSES': (          'rest_framework.authentication.TokenAuthentication', | 
