We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Move to WebPack
Building the frontend is annoying, and updating dependencies in a way that lets us test the updates is nothing short of tedious.

WebPack with proper bounds on the minor version of each component and dependency should help us stay in line and keep up to date with the frontend code.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `backend/uclapi/uclapi/settings.py`
Content:
```
1 """
2 Django settings for uclapi project.
3 
4 Generated by 'django-admin startproject' using Django 1.10.4.
5 
6 For more information on this file, see
7 https://docs.djangoproject.com/en/1.10/topics/settings/
8 
9 For the full list of settings and their values, see
10 https://docs.djangoproject.com/en/1.10/ref/settings/
11 """
12 
13 import os
14 import requests
15 from distutils.util import strtobool
16 
17 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
18 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
19 
20 
21 # Quick-start development settings - unsuitable for production
22 # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
23 
24 # SECURITY WARNING: keep the secret key used in production secret!
25 SECRET_KEY = os.environ.get("SECRET_KEY")
26 
27 # SECURITY WARNING: don't run with debug turned on in production!
28 # This value should be set by the UCLAPI_PRODUCTION environment
29 # variable anyway. If in production, debug should be false.
30 DEBUG = not strtobool(os.environ.get("UCLAPI_PRODUCTION"))
31 
32 ALLOWED_HOSTS = ["localhost"]
33 
34 # If a domain is specified then make this an allowed host
35 if os.environ.get("UCLAPI_DOMAIN"):
36     ALLOWED_HOSTS.append(os.environ.get("UCLAPI_DOMAIN"))
37 
38 # If we are running under the AWS Elastic Load Balancer then enable internal
39 # requests so that the ELB and Health Checks work
40 if strtobool(os.environ.get("UCLAPI_RUNNING_ON_AWS_ELB")):
41     EC2_PRIVATE_IP = None
42     try:
43         EC2_PRIVATE_IP = requests.get(
44             "http://169.254.169.254/latest/meta-data/local-ipv4",
45             timeout=0.01
46         ).text
47     except requests.exceptions.RequestException:
48         pass
49 
50     if EC2_PRIVATE_IP:
51         ALLOWED_HOSTS.append(EC2_PRIVATE_IP)
52 
53 # Application definition
54 
55 INSTALLED_APPS = [
56     'django.contrib.admin',
57     'django.contrib.auth',
58     'django.contrib.contenttypes',
59     'django.contrib.sessions',
60     'django.contrib.messages',
61     'django.contrib.staticfiles',
62     'rest_framework',
63     'dashboard',
64     'marketplace',
65     'roombookings',
66     'oauth',
67     'timetable',
68     'common',
69     'opbeat.contrib.django',
70     'raven.contrib.django.raven_compat',
71     'corsheaders',
72     'workspaces'
73 ]
74 
75 MIDDLEWARE = [
76     'opbeat.contrib.django.middleware.OpbeatAPMMiddleware',
77     'django.middleware.security.SecurityMiddleware',
78     'django.contrib.sessions.middleware.SessionMiddleware',
79     'corsheaders.middleware.CorsMiddleware',
80     'django.middleware.common.CommonMiddleware',
81     'django.middleware.csrf.CsrfViewMiddleware',
82     'django.contrib.auth.middleware.AuthenticationMiddleware',
83     'django.contrib.messages.middleware.MessageMiddleware',
84     'django.middleware.clickjacking.XFrameOptionsMiddleware',
85 ]
86 
87 if DEBUG:
88     MIDDLEWARE.append(
89         'dashboard.middleware.fake_shibboleth_middleware'
90         '.FakeShibbolethMiddleWare'
91     )
92 
93 ROOT_URLCONF = 'uclapi.urls'
94 
95 TEMPLATES = [
96     {
97         'BACKEND': 'django.template.backends.django.DjangoTemplates',
98         'DIRS': [],
99         'APP_DIRS': True,
100         'OPTIONS': {
101             'context_processors': [
102                 'django.template.context_processors.debug',
103                 'django.template.context_processors.request',
104                 'django.contrib.auth.context_processors.auth',
105                 'django.contrib.messages.context_processors.messages',
106             ],
107         },
108     },
109 ]
110 
111 WSGI_APPLICATION = 'uclapi.wsgi.application'
112 
113 
114 # Database
115 # https://docs.djangoproject.com/en/1.10/ref/settings/#databases
116 
117 DATABASES = {
118     'default': {
119         'ENGINE': 'django.db.backends.postgresql',
120         'NAME': os.environ.get("DB_UCLAPI_NAME"),
121         'USER': os.environ.get("DB_UCLAPI_USERNAME"),
122         'PASSWORD': os.environ.get("DB_UCLAPI_PASSWORD"),
123         'HOST': os.environ.get("DB_UCLAPI_HOST"),
124         'PORT': os.environ.get("DB_UCLAPI_PORT")
125     },
126     'roombookings': {
127         'ENGINE': 'django.db.backends.oracle',
128         'NAME': os.environ.get("DB_ROOMS_NAME"),
129         'USER': os.environ.get("DB_ROOMS_USERNAME"),
130         'PASSWORD': os.environ.get("DB_ROOMS_PASSWORD"),
131         'HOST': '',
132         'PORT': ''
133     },
134     'gencache': {
135         'ENGINE': 'django.db.backends.postgresql',
136         'NAME': os.environ.get("DB_CACHE_NAME"),
137         'USER': os.environ.get("DB_CACHE_USERNAME"),
138         'PASSWORD': os.environ.get("DB_CACHE_PASSWORD"),
139         'HOST': os.environ.get("DB_CACHE_HOST"),
140         'PORT': os.environ.get("DB_CACHE_PORT")
141     }
142 }
143 
144 DATABASE_ROUTERS = ['uclapi.dbrouters.ModelRouter']
145 
146 # analytics
147 OPBEAT = {
148     'ORGANIZATION_ID': os.environ.get("OPBEAT_ORG_ID"),
149     'APP_ID': os.environ.get("OPBEAT_APP_ID"),
150     'SECRET_TOKEN': os.environ.get("OPBEAT_SECRET_TOKEN")
151 }
152 
153 RAVEN_CONFIG = {
154     'dsn': os.environ.get("SENTRY_DSN"),
155 }
156 
157 
158 # Password validation
159 # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
160 
161 AUTH_PASSWORD_VALIDATORS = [
162     {
163         'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',  # noqa
164     },
165     {
166         'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',  # noqa
167     },
168     {
169         'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',  # noqa
170     },
171     {
172         'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',  # noqa
173     },
174 ]
175 
176 
177 # Internationalization
178 # https://docs.djangoproject.com/en/1.10/topics/i18n/
179 
180 LANGUAGE_CODE = 'en-us'
181 
182 TIME_ZONE = 'UTC'
183 
184 USE_I18N = True
185 
186 USE_L10N = True
187 
188 USE_TZ = False
189 
190 
191 # Static files (CSS, JavaScript, Images)
192 # https://docs.djangoproject.com/en/1.10/howto/static-files/
193 
194 STATIC_URL = '/static/'
195 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
196 STATICFILES_DIRS = [
197     os.path.join(BASE_DIR, "images"),
198 ]
199 
200 # Cross Origin settings
201 CORS_ORIGIN_ALLOW_ALL = True
202 CORS_URLS_REGEX = r'^/roombookings/.*$'
203 
204 # Fair use policy
205 fair_use_policy_path = os.path.join(
206     BASE_DIR,
207     'uclapi/UCLAPIAcceptableUsePolicy.txt'
208 )
209 with open(fair_use_policy_path, 'r', encoding='utf-8') as fp:
210     FAIR_USE_POLICY = list(fp)
211 
212 REDIS_UCLAPI_HOST = os.environ["REDIS_UCLAPI_HOST"]
213 
214 # Celery Settings
215 CELERY_BROKER_URL = 'redis://' + REDIS_UCLAPI_HOST
216 CELERY_ACCEPT_CONTENT = ['json']
217 CELERY_TASK_SERIALIZER = 'json'
218 CELERY_RESULT_SERIALIZER = 'json'
219 
220 
221 ROOMBOOKINGS_SETID = 'LIVE-17-18'
222 
223 # S3 file storage settings
224 # There are three scenarios to consider:
225 # 1) Local development
226 #    In local dev,  AWS_S3_STATICS = False
227 #                   AWS_S3_STATICS_CREDENTIALS_ENABLED = False
228 #    These allow you to use local statics using /static/ in the
229 #    same way as you would normally.
230 # 2) Production
231 #    In prod,       AWS_S3_STATICS = True
232 #                   AWS_S3_STATICS_CREDENTIALS_ENABLED = False
233 #    This means that S3 statics will be used, but no creds are
234 #    needed on the boxes because web servers should never do
235 #    uploads to the remote S3 bucket.
236 # 3) Deployment
237 #    In deployment, AWS_S3_STATICS = True
238 #                   AWS_S3_STATICS_CREDENTIALS_ENABLED = True
239 #    This will be done either from CI/CD or from the computer
240 #    of a person who has permission to upload new statics to
241 #    S3.
242 
243 if strtobool(os.environ.get("AWS_S3_STATICS", "False")):
244     DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
245     STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
246     AWS_STORAGE_BUCKET_NAME = os.environ["AWS_S3_BUCKET_NAME"]
247     AWS_LOCATION = os.environ["AWS_S3_BUCKET_PATH"]
248     AWS_S3_REGION_NAME = os.environ["AWS_S3_REGION"]
249 
250     # This is a hack to not require AWS Access Credentials
251     # when the system is running in the Cloud. This avoids us from
252     # needing to store AWS credentials.
253     # https://github.com/jschneier/django-storages/issues/254#issuecomment-329813295  # noqa
254     AWS_S3_CUSTOM_DOMAIN = "{}.s3.amazonaws.com".format(
255         AWS_STORAGE_BUCKET_NAME
256     )
257 
258     # If credentials are enabled, collectstatic can do uploads
259     if strtobool(os.environ["AWS_S3_STATICS_CREDENTIALS_ENABLED"]):
260         AWS_ACCESS_KEY_ID = os.environ["AWS_ACCESS_KEY_ID"]
261         AWS_SECRET_ACCESS_KEY = os.environ["AWS_ACCESS_SECRET"]
262         AWS_S3_OBJECT_PARAMETERS = {
263             'CacheControl': 'max-age=86400',
264         }
265         AWS_S3_ENCRYPTION = False
266     else:
267         AWS_QUERYSTRING_AUTH = False
268
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/backend/uclapi/uclapi/settings.py b/backend/uclapi/uclapi/settings.py
--- a/backend/uclapi/uclapi/settings.py
+++ b/backend/uclapi/uclapi/settings.py
@@ -187,15 +187,11 @@
 
 USE_TZ = False
 
-
 # Static files (CSS, JavaScript, Images)
 # https://docs.djangoproject.com/en/1.10/howto/static-files/
 
 STATIC_URL = '/static/'
 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
-STATICFILES_DIRS = [
-    os.path.join(BASE_DIR, "images"),
-]
 
 # Cross Origin settings
 CORS_ORIGIN_ALLOW_ALL = True

{"golden_diff": "diff --git a/backend/uclapi/uclapi/settings.py b/backend/uclapi/uclapi/settings.py\n--- a/backend/uclapi/uclapi/settings.py\n+++ b/backend/uclapi/uclapi/settings.py\n@@ -187,15 +187,11 @@\n \n USE_TZ = False\n \n-\n # Static files (CSS, JavaScript, Images)\n # https://docs.djangoproject.com/en/1.10/howto/static-files/\n \n STATIC_URL = '/static/'\n STATIC_ROOT = os.path.join(BASE_DIR, 'static')\n-STATICFILES_DIRS = [\n-    os.path.join(BASE_DIR, \"images\"),\n-]\n \n # Cross Origin settings\n CORS_ORIGIN_ALLOW_ALL = True\n", "issue": "Move to WebPack\nBuilding the frontend is annoying, and updating dependencies in a way that lets us test the updates is nothing short of tedious.\r\n\r\nWebPack with proper bounds on the minor version of each component and dependency should help us stay in line and keep up to date with the frontend code.\n", "before_files": [{"content": "\"\"\"\nDjango settings for uclapi project.\n\nGenerated by 'django-admin startproject' using Django 1.10.4.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/1.10/topics/settings/\n\nFor the full list of settings and their values, see\nhttps://docs.djangoproject.com/en/1.10/ref/settings/\n\"\"\"\n\nimport os\nimport requests\nfrom distutils.util import strtobool\n\n# Build paths inside the project like this: os.path.join(BASE_DIR, ...)\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = os.environ.get(\"SECRET_KEY\")\n\n# SECURITY WARNING: don't run with debug turned on in production!\n# This value should be set by the UCLAPI_PRODUCTION environment\n# variable anyway. If in production, debug should be false.\nDEBUG = not strtobool(os.environ.get(\"UCLAPI_PRODUCTION\"))\n\nALLOWED_HOSTS = [\"localhost\"]\n\n# If a domain is specified then make this an allowed host\nif os.environ.get(\"UCLAPI_DOMAIN\"):\n    ALLOWED_HOSTS.append(os.environ.get(\"UCLAPI_DOMAIN\"))\n\n# If we are running under the AWS Elastic Load Balancer then enable internal\n# requests so that the ELB and Health Checks work\nif strtobool(os.environ.get(\"UCLAPI_RUNNING_ON_AWS_ELB\")):\n    EC2_PRIVATE_IP = None\n    try:\n        EC2_PRIVATE_IP = requests.get(\n            \"http://169.254.169.254/latest/meta-data/local-ipv4\",\n            timeout=0.01\n        ).text\n    except requests.exceptions.RequestException:\n        pass\n\n    if EC2_PRIVATE_IP:\n        ALLOWED_HOSTS.append(EC2_PRIVATE_IP)\n\n# Application definition\n\nINSTALLED_APPS = [\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'rest_framework',\n    'dashboard',\n    'marketplace',\n    'roombookings',\n    'oauth',\n    'timetable',\n    'common',\n    'opbeat.contrib.django',\n    'raven.contrib.django.raven_compat',\n    'corsheaders',\n    'workspaces'\n]\n\nMIDDLEWARE = [\n    'opbeat.contrib.django.middleware.OpbeatAPMMiddleware',\n    'django.middleware.security.SecurityMiddleware',\n    'django.contrib.sessions.middleware.SessionMiddleware',\n    'corsheaders.middleware.CorsMiddleware',\n    'django.middleware.common.CommonMiddleware',\n    'django.middleware.csrf.CsrfViewMiddleware',\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\n    'django.contrib.messages.middleware.MessageMiddleware',\n    'django.middleware.clickjacking.XFrameOptionsMiddleware',\n]\n\nif DEBUG:\n    MIDDLEWARE.append(\n        'dashboard.middleware.fake_shibboleth_middleware'\n        '.FakeShibbolethMiddleWare'\n    )\n\nROOT_URLCONF = 'uclapi.urls'\n\nTEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'DIRS': [],\n        'APP_DIRS': True,\n        'OPTIONS': {\n            'context_processors': [\n                'django.template.context_processors.debug',\n                'django.template.context_processors.request',\n                'django.contrib.auth.context_processors.auth',\n                'django.contrib.messages.context_processors.messages',\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = 'uclapi.wsgi.application'\n\n\n# Database\n# https://docs.djangoproject.com/en/1.10/ref/settings/#databases\n\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.postgresql',\n        'NAME': os.environ.get(\"DB_UCLAPI_NAME\"),\n        'USER': os.environ.get(\"DB_UCLAPI_USERNAME\"),\n        'PASSWORD': os.environ.get(\"DB_UCLAPI_PASSWORD\"),\n        'HOST': os.environ.get(\"DB_UCLAPI_HOST\"),\n        'PORT': os.environ.get(\"DB_UCLAPI_PORT\")\n    },\n    'roombookings': {\n        'ENGINE': 'django.db.backends.oracle',\n        'NAME': os.environ.get(\"DB_ROOMS_NAME\"),\n        'USER': os.environ.get(\"DB_ROOMS_USERNAME\"),\n        'PASSWORD': os.environ.get(\"DB_ROOMS_PASSWORD\"),\n        'HOST': '',\n        'PORT': ''\n    },\n    'gencache': {\n        'ENGINE': 'django.db.backends.postgresql',\n        'NAME': os.environ.get(\"DB_CACHE_NAME\"),\n        'USER': os.environ.get(\"DB_CACHE_USERNAME\"),\n        'PASSWORD': os.environ.get(\"DB_CACHE_PASSWORD\"),\n        'HOST': os.environ.get(\"DB_CACHE_HOST\"),\n        'PORT': os.environ.get(\"DB_CACHE_PORT\")\n    }\n}\n\nDATABASE_ROUTERS = ['uclapi.dbrouters.ModelRouter']\n\n# analytics\nOPBEAT = {\n    'ORGANIZATION_ID': os.environ.get(\"OPBEAT_ORG_ID\"),\n    'APP_ID': os.environ.get(\"OPBEAT_APP_ID\"),\n    'SECRET_TOKEN': os.environ.get(\"OPBEAT_SECRET_TOKEN\")\n}\n\nRAVEN_CONFIG = {\n    'dsn': os.environ.get(\"SENTRY_DSN\"),\n}\n\n\n# Password validation\n# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',  # noqa\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',  # noqa\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',  # noqa\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',  # noqa\n    },\n]\n\n\n# Internationalization\n# https://docs.djangoproject.com/en/1.10/topics/i18n/\n\nLANGUAGE_CODE = 'en-us'\n\nTIME_ZONE = 'UTC'\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = False\n\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/1.10/howto/static-files/\n\nSTATIC_URL = '/static/'\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')\nSTATICFILES_DIRS = [\n    os.path.join(BASE_DIR, \"images\"),\n]\n\n# Cross Origin settings\nCORS_ORIGIN_ALLOW_ALL = True\nCORS_URLS_REGEX = r'^/roombookings/.*$'\n\n# Fair use policy\nfair_use_policy_path = os.path.join(\n    BASE_DIR,\n    'uclapi/UCLAPIAcceptableUsePolicy.txt'\n)\nwith open(fair_use_policy_path, 'r', encoding='utf-8') as fp:\n    FAIR_USE_POLICY = list(fp)\n\nREDIS_UCLAPI_HOST = os.environ[\"REDIS_UCLAPI_HOST\"]\n\n# Celery Settings\nCELERY_BROKER_URL = 'redis://' + REDIS_UCLAPI_HOST\nCELERY_ACCEPT_CONTENT = ['json']\nCELERY_TASK_SERIALIZER = 'json'\nCELERY_RESULT_SERIALIZER = 'json'\n\n\nROOMBOOKINGS_SETID = 'LIVE-17-18'\n\n# S3 file storage settings\n# There are three scenarios to consider:\n# 1) Local development\n#    In local dev,  AWS_S3_STATICS = False\n#                   AWS_S3_STATICS_CREDENTIALS_ENABLED = False\n#    These allow you to use local statics using /static/ in the\n#    same way as you would normally.\n# 2) Production\n#    In prod,       AWS_S3_STATICS = True\n#                   AWS_S3_STATICS_CREDENTIALS_ENABLED = False\n#    This means that S3 statics will be used, but no creds are\n#    needed on the boxes because web servers should never do\n#    uploads to the remote S3 bucket.\n# 3) Deployment\n#    In deployment, AWS_S3_STATICS = True\n#                   AWS_S3_STATICS_CREDENTIALS_ENABLED = True\n#    This will be done either from CI/CD or from the computer\n#    of a person who has permission to upload new statics to\n#    S3.\n\nif strtobool(os.environ.get(\"AWS_S3_STATICS\", \"False\")):\n    DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'\n    STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'\n    AWS_STORAGE_BUCKET_NAME = os.environ[\"AWS_S3_BUCKET_NAME\"]\n    AWS_LOCATION = os.environ[\"AWS_S3_BUCKET_PATH\"]\n    AWS_S3_REGION_NAME = os.environ[\"AWS_S3_REGION\"]\n\n    # This is a hack to not require AWS Access Credentials\n    # when the system is running in the Cloud. This avoids us from\n    # needing to store AWS credentials.\n    # https://github.com/jschneier/django-storages/issues/254#issuecomment-329813295  # noqa\n    AWS_S3_CUSTOM_DOMAIN = \"{}.s3.amazonaws.com\".format(\n        AWS_STORAGE_BUCKET_NAME\n    )\n\n    # If credentials are enabled, collectstatic can do uploads\n    if strtobool(os.environ[\"AWS_S3_STATICS_CREDENTIALS_ENABLED\"]):\n        AWS_ACCESS_KEY_ID = os.environ[\"AWS_ACCESS_KEY_ID\"]\n        AWS_SECRET_ACCESS_KEY = os.environ[\"AWS_ACCESS_SECRET\"]\n        AWS_S3_OBJECT_PARAMETERS = {\n            'CacheControl': 'max-age=86400',\n        }\n        AWS_S3_ENCRYPTION = False\n    else:\n        AWS_QUERYSTRING_AUTH = False\n", "path": "backend/uclapi/uclapi/settings.py"}], "after_files": [{"content": "\"\"\"\nDjango settings for uclapi project.\n\nGenerated by 'django-admin startproject' using Django 1.10.4.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/1.10/topics/settings/\n\nFor the full list of settings and their values, see\nhttps://docs.djangoproject.com/en/1.10/ref/settings/\n\"\"\"\n\nimport os\nimport requests\nfrom distutils.util import strtobool\n\n# Build paths inside the project like this: os.path.join(BASE_DIR, ...)\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = os.environ.get(\"SECRET_KEY\")\n\n# SECURITY WARNING: don't run with debug turned on in production!\n# This value should be set by the UCLAPI_PRODUCTION environment\n# variable anyway. If in production, debug should be false.\nDEBUG = not strtobool(os.environ.get(\"UCLAPI_PRODUCTION\"))\n\nALLOWED_HOSTS = [\"localhost\"]\n\n# If a domain is specified then make this an allowed host\nif os.environ.get(\"UCLAPI_DOMAIN\"):\n    ALLOWED_HOSTS.append(os.environ.get(\"UCLAPI_DOMAIN\"))\n\n# If we are running under the AWS Elastic Load Balancer then enable internal\n# requests so that the ELB and Health Checks work\nif strtobool(os.environ.get(\"UCLAPI_RUNNING_ON_AWS_ELB\")):\n    EC2_PRIVATE_IP = None\n    try:\n        EC2_PRIVATE_IP = requests.get(\n            \"http://169.254.169.254/latest/meta-data/local-ipv4\",\n            timeout=0.01\n        ).text\n    except requests.exceptions.RequestException:\n        pass\n\n    if EC2_PRIVATE_IP:\n        ALLOWED_HOSTS.append(EC2_PRIVATE_IP)\n\n# Application definition\n\nINSTALLED_APPS = [\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'rest_framework',\n    'dashboard',\n    'marketplace',\n    'roombookings',\n    'oauth',\n    'timetable',\n    'common',\n    'opbeat.contrib.django',\n    'raven.contrib.django.raven_compat',\n    'corsheaders',\n    'workspaces'\n]\n\nMIDDLEWARE = [\n    'opbeat.contrib.django.middleware.OpbeatAPMMiddleware',\n    'django.middleware.security.SecurityMiddleware',\n    'django.contrib.sessions.middleware.SessionMiddleware',\n    'corsheaders.middleware.CorsMiddleware',\n    'django.middleware.common.CommonMiddleware',\n    'django.middleware.csrf.CsrfViewMiddleware',\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\n    'django.contrib.messages.middleware.MessageMiddleware',\n    'django.middleware.clickjacking.XFrameOptionsMiddleware',\n]\n\nif DEBUG:\n    MIDDLEWARE.append(\n        'dashboard.middleware.fake_shibboleth_middleware'\n        '.FakeShibbolethMiddleWare'\n    )\n\nROOT_URLCONF = 'uclapi.urls'\n\nTEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'DIRS': [],\n        'APP_DIRS': True,\n        'OPTIONS': {\n            'context_processors': [\n                'django.template.context_processors.debug',\n                'django.template.context_processors.request',\n                'django.contrib.auth.context_processors.auth',\n                'django.contrib.messages.context_processors.messages',\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = 'uclapi.wsgi.application'\n\n\n# Database\n# https://docs.djangoproject.com/en/1.10/ref/settings/#databases\n\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.postgresql',\n        'NAME': os.environ.get(\"DB_UCLAPI_NAME\"),\n        'USER': os.environ.get(\"DB_UCLAPI_USERNAME\"),\n        'PASSWORD': os.environ.get(\"DB_UCLAPI_PASSWORD\"),\n        'HOST': os.environ.get(\"DB_UCLAPI_HOST\"),\n        'PORT': os.environ.get(\"DB_UCLAPI_PORT\")\n    },\n    'roombookings': {\n        'ENGINE': 'django.db.backends.oracle',\n        'NAME': os.environ.get(\"DB_ROOMS_NAME\"),\n        'USER': os.environ.get(\"DB_ROOMS_USERNAME\"),\n        'PASSWORD': os.environ.get(\"DB_ROOMS_PASSWORD\"),\n        'HOST': '',\n        'PORT': ''\n    },\n    'gencache': {\n        'ENGINE': 'django.db.backends.postgresql',\n        'NAME': os.environ.get(\"DB_CACHE_NAME\"),\n        'USER': os.environ.get(\"DB_CACHE_USERNAME\"),\n        'PASSWORD': os.environ.get(\"DB_CACHE_PASSWORD\"),\n        'HOST': os.environ.get(\"DB_CACHE_HOST\"),\n        'PORT': os.environ.get(\"DB_CACHE_PORT\")\n    }\n}\n\nDATABASE_ROUTERS = ['uclapi.dbrouters.ModelRouter']\n\n# analytics\nOPBEAT = {\n    'ORGANIZATION_ID': os.environ.get(\"OPBEAT_ORG_ID\"),\n    'APP_ID': os.environ.get(\"OPBEAT_APP_ID\"),\n    'SECRET_TOKEN': os.environ.get(\"OPBEAT_SECRET_TOKEN\")\n}\n\nRAVEN_CONFIG = {\n    'dsn': os.environ.get(\"SENTRY_DSN\"),\n}\n\n\n# Password validation\n# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',  # noqa\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',  # noqa\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',  # noqa\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',  # noqa\n    },\n]\n\n\n# Internationalization\n# https://docs.djangoproject.com/en/1.10/topics/i18n/\n\nLANGUAGE_CODE = 'en-us'\n\nTIME_ZONE = 'UTC'\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = False\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/1.10/howto/static-files/\n\nSTATIC_URL = '/static/'\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')\n\n# Cross Origin settings\nCORS_ORIGIN_ALLOW_ALL = True\nCORS_URLS_REGEX = r'^/roombookings/.*$'\n\n# Fair use policy\nfair_use_policy_path = os.path.join(\n    BASE_DIR,\n    'uclapi/UCLAPIAcceptableUsePolicy.txt'\n)\nwith open(fair_use_policy_path, 'r', encoding='utf-8') as fp:\n    FAIR_USE_POLICY = list(fp)\n\nREDIS_UCLAPI_HOST = os.environ[\"REDIS_UCLAPI_HOST\"]\n\n# Celery Settings\nCELERY_BROKER_URL = 'redis://' + REDIS_UCLAPI_HOST\nCELERY_ACCEPT_CONTENT = ['json']\nCELERY_TASK_SERIALIZER = 'json'\nCELERY_RESULT_SERIALIZER = 'json'\n\n\nROOMBOOKINGS_SETID = 'LIVE-17-18'\n\n# S3 file storage settings\n# There are three scenarios to consider:\n# 1) Local development\n#    In local dev,  AWS_S3_STATICS = False\n#                   AWS_S3_STATICS_CREDENTIALS_ENABLED = False\n#    These allow you to use local statics using /static/ in the\n#    same way as you would normally.\n# 2) Production\n#    In prod,       AWS_S3_STATICS = True\n#                   AWS_S3_STATICS_CREDENTIALS_ENABLED = False\n#    This means that S3 statics will be used, but no creds are\n#    needed on the boxes because web servers should never do\n#    uploads to the remote S3 bucket.\n# 3) Deployment\n#    In deployment, AWS_S3_STATICS = True\n#                   AWS_S3_STATICS_CREDENTIALS_ENABLED = True\n#    This will be done either from CI/CD or from the computer\n#    of a person who has permission to upload new statics to\n#    S3.\n\nif strtobool(os.environ.get(\"AWS_S3_STATICS\", \"False\")):\n    DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'\n    STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'\n    AWS_STORAGE_BUCKET_NAME = os.environ[\"AWS_S3_BUCKET_NAME\"]\n    AWS_LOCATION = os.environ[\"AWS_S3_BUCKET_PATH\"]\n    AWS_S3_REGION_NAME = os.environ[\"AWS_S3_REGION\"]\n\n    # This is a hack to not require AWS Access Credentials\n    # when the system is running in the Cloud. This avoids us from\n    # needing to store AWS credentials.\n    # https://github.com/jschneier/django-storages/issues/254#issuecomment-329813295  # noqa\n    AWS_S3_CUSTOM_DOMAIN = \"{}.s3.amazonaws.com\".format(\n        AWS_STORAGE_BUCKET_NAME\n    )\n\n    # If credentials are enabled, collectstatic can do uploads\n    if strtobool(os.environ[\"AWS_S3_STATICS_CREDENTIALS_ENABLED\"]):\n        AWS_ACCESS_KEY_ID = os.environ[\"AWS_ACCESS_KEY_ID\"]\n        AWS_SECRET_ACCESS_KEY = os.environ[\"AWS_ACCESS_SECRET\"]\n        AWS_S3_OBJECT_PARAMETERS = {\n            'CacheControl': 'max-age=86400',\n        }\n        AWS_S3_ENCRYPTION = False\n    else:\n        AWS_QUERYSTRING_AUTH = False\n", "path": "backend/uclapi/uclapi/settings.py"}]}