|
28 | 28 | "django.contrib.staticfiles", |
29 | 29 | # Third party apps |
30 | 30 | "django_extensions", |
| 31 | + "django_tasks", |
| 32 | + "django_tasks.backends.database", |
31 | 33 | # Project apps |
32 | 34 | "core", |
33 | 35 | ] |
|
127 | 129 | } |
128 | 130 | } |
129 | 131 |
|
| 132 | + TASKS = { |
| 133 | + "default": { |
| 134 | + "BACKEND": "django_tasks.backends.database.DatabaseBackend", |
| 135 | + } |
| 136 | + } |
| 137 | + |
130 | 138 | WEBHOOK_INTERNAL_TOKEN = "dev-token" |
131 | 139 |
|
132 | 140 | # This is only needed if you end up running the bot locally, hence it |
|
135 | 143 | # one from the developer portal. |
136 | 144 | # If you run it locally, you probably want to run it against your own test |
137 | 145 | # bot and a test server. |
138 | | - DISCORD_BOT_TOKEN = os.environ.get("DISCORD_BOT_TOKEN", "") |
139 | | - if not DISCORD_BOT_TOKEN: |
140 | | - warnings.warn("DISCORD_BOT_TOKEN not set") |
| 146 | + |
| 147 | + def warn_if_missing(name, default=""): |
| 148 | + value = os.environ.get(name, default) |
| 149 | + if not value: |
| 150 | + warnings.warn(f"{name} not set") |
| 151 | + |
| 152 | + DISCORD_TEST_CHANNEL_ID = warn_if_missing("DISCORD_TEST_CHANNEL_ID", "") |
| 153 | + DISCORD_TEST_CHANNEL_NAME = warn_if_missing("DISCORD_TEST_CHANNEL_NAME", "") |
| 154 | + DISCORD_BOT_TOKEN = warn_if_missing("DISCORD_BOT_TOKEN", "") |
| 155 | + |
141 | 156 |
|
142 | 157 | elif DJANGO_ENV == "test": |
143 | 158 | DEBUG = True |
|
158 | 173 |
|
159 | 174 | WEBHOOK_INTERNAL_TOKEN = "test-random-token" |
160 | 175 |
|
| 176 | + TASKS = { |
| 177 | + "default": { |
| 178 | + "BACKEND": "django_tasks.backends.immediate.ImmediateBackend", |
| 179 | + # This setting doesn't really make sense in this context, but it |
| 180 | + # makes it work in the test environment... |
| 181 | + # TODO(artcz): Let's figure out later why. |
| 182 | + # NOTE: in django-tasks tests the test harness seem to be quite |
| 183 | + # different so maybe there's also something we can check in the |
| 184 | + # library itself. |
| 185 | + "ENQUEUE_ON_COMMIT": False, |
| 186 | + } |
| 187 | + } |
| 188 | + |
| 189 | + DISCORD_TEST_CHANNEL_ID = "12345" |
| 190 | + DISCORD_TEST_CHANNEL_NAME = "#test-channel" |
| 191 | + |
161 | 192 |
|
162 | 193 | elif DJANGO_ENV == "local_container": |
163 | 194 | DEBUG = False |
|
179 | 210 | } |
180 | 211 | } |
181 | 212 |
|
| 213 | + TASKS = { |
| 214 | + "default": { |
| 215 | + "BACKEND": "django_tasks.backends.database.DatabaseBackend", |
| 216 | + } |
| 217 | + } |
| 218 | + |
182 | 219 | # For 500 errors to appear on stderr |
183 | 220 | LOGGING = { |
184 | 221 | "version": 1, |
|
220 | 257 | } |
221 | 258 | } |
222 | 259 |
|
| 260 | + TASKS = { |
| 261 | + "default": { |
| 262 | + "BACKEND": "django_tasks.backends.database.DatabaseBackend", |
| 263 | + } |
| 264 | + } |
| 265 | + |
223 | 266 | # For 500 errors to appear on stderr |
224 | 267 | # For now it's good for docker, in the future sentry/or rollabar should be |
225 | 268 | # here |
|
242 | 285 | } |
243 | 286 |
|
244 | 287 | DISCORD_BOT_TOKEN = os.environ["DISCORD_BOT_TOKEN"] |
| 288 | + DISCORD_TEST_CHANNEL_ID = os.environ["DISCORD_TEST_CHANNEL_ID"] |
| 289 | + DISCORD_TEST_CHANNEL_NAME = os.environ["DISCORD_TEST_CHANNEL_NAME"] |
245 | 290 |
|
246 | 291 | CSRF_TRUSTED_ORIGINS = [ |
247 | 292 | "https://internal.europython.eu", |
|
0 commit comments