|
2 | 2 | Django settings for manatee project.
|
3 | 3 | """
|
4 | 4 |
|
| 5 | +try: |
| 6 | + import tomllib |
| 7 | +except ImportError: |
| 8 | + from pip._vendor import tomli as tomllib |
| 9 | + |
5 | 10 | import json
|
6 | 11 | import os
|
7 | 12 | import sys
|
8 | 13 | import arches
|
9 | 14 | import inspect
|
10 | 15 | import semantic_version
|
11 | 16 | from django.utils.translation import gettext_lazy as _
|
| 17 | +from datetime import datetime, timedelta |
12 | 18 |
|
13 | 19 | try:
|
14 | 20 | from arches.settings import *
|
|
137 | 143 | PG_SUPERUSER = ""
|
138 | 144 | PG_SUPERUSER_PW = ""
|
139 | 145 |
|
| 146 | +# SECURITY WARNING: don't run with debug turned on in production! |
140 | 147 | # from http://django-guardian.readthedocs.io/en/stable/configuration.html#anonymous-user-name
|
141 | 148 | ANONYMOUS_USER_NAME = None
|
142 | 149 |
|
|
145 | 152 | SEARCH_THUMBNAILS = False
|
146 | 153 | # see http://elasticsearch-py.readthedocs.org/en/master/api.html#elasticsearch.Elasticsearch
|
147 | 154 | ELASTICSEARCH_HOSTS = [{"scheme": "https", "host": "localhost", "port": ELASTICSEARCH_HTTP_PORT}]
|
| 155 | +DEBUG = False |
148 | 156 |
|
149 | 157 | ROOT_URLCONF = 'manatee.urls'
|
150 | 158 |
|
|
210 | 218 | }
|
211 | 219 | }
|
212 | 220 |
|
| 221 | +SEARCH_THUMBNAILS = False |
| 222 | + |
213 | 223 | INSTALLED_APPS = (
|
214 | 224 | "webpack_loader",
|
215 | 225 | "django.contrib.admin",
|
|
255 | 265 | "arches.app.utils.middleware.SetAnonymousUser",
|
256 | 266 | # "silk.middleware.SilkyMiddleware",
|
257 | 267 | ]
|
| 268 | +if DEBUG: |
| 269 | + MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware") |
| 270 | + MIDDLEWARE.append("debug_toolbar_force.middleware.ForceDebugToolbarMiddleware") |
| 271 | + import socket |
| 272 | + hostname, __, ips = socket.gethostbyname_ex(socket.gethostname()) |
| 273 | + INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + ["127.0.0.1", "10.0.2.2"] |
| 274 | + |
258 | 275 |
|
259 | 276 | STATICFILES_DIRS = build_staticfiles_dirs(
|
260 | 277 | root_dir=ROOT_DIR,
|
261 | 278 | app_root=APP_ROOT,
|
262 | 279 | arches_applications=ARCHES_APPLICATIONS,
|
263 | 280 | )
|
264 | 281 |
|
| 282 | +SERVE_STATIC = os.getenv("SERVE_STATIC", "True") == "True" |
| 283 | + |
265 | 284 | TEMPLATES = build_templates_config(
|
266 | 285 | root_dir=ROOT_DIR,
|
267 | 286 | debug=DEBUG,
|
|
294 | 313 | # when hosting Arches under a sub path set this value to the sub path eg : "/{sub_path}/"
|
295 | 314 | FORCE_SCRIPT_NAME = None
|
296 | 315 |
|
| 316 | +FORCE_USER_SIGNUP_EMAIL_AUTHENTICATION = False |
297 | 317 | RESOURCE_IMPORT_LOG = os.path.join(APP_ROOT, 'logs', 'resource_import.log')
|
298 | 318 | DEFAULT_RESOURCE_IMPORT_USER = {'username': 'admin', 'userid': 1}
|
299 | 319 |
|
|
311 | 331 | else:
|
312 | 332 | PERMISSION_FRAMEWORK = "arches_allow_with_credentials.ArchesAllowWithCredentialsFramework"
|
313 | 333 |
|
| 334 | +if (LOG_LEVEL := os.getenv("LOG_LEVEL", "")): |
| 335 | + pass |
| 336 | +elif DEBUG or {os.getenv(debug_env, "False").lower() for debug_env in ("DJANGO_DEBUG", "DEBUG")} & {"true", "1"}: |
| 337 | + LOG_LEVEL = "DEBUG" |
| 338 | +else: |
| 339 | + LOG_LEVEL = "WARNING" |
| 340 | + |
314 | 341 | LOGGING = {
|
315 | 342 | 'version': 1,
|
316 | 343 | 'disable_existing_loggers': False,
|
|
341 | 368 | }
|
342 | 369 | }
|
343 | 370 |
|
| 371 | +# Rate limit for authentication views |
| 372 | +# See options (including None or python callables): |
| 373 | +# https://django-ratelimit.readthedocs.io/en/stable/rates.html#rates-chapter |
| 374 | +RATE_LIMIT = "5/m" |
344 | 375 |
|
345 | 376 | # Sets default max upload size to 15MB
|
346 | 377 | DATA_UPLOAD_MAX_MEMORY_SIZE = 15728640
|
|
351 | 382 | # For more info on configuring your cache: https://docs.djangoproject.com/en/2.2/topics/cache/
|
352 | 383 | CACHES = {
|
353 | 384 | 'default': {
|
354 |
| - 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', |
| 385 | + "BACKEND": "django.core.cache.backends.locmem.LocMemCache", |
| 386 | + "LOCATION": "unique-snowflake" |
355 | 387 | },
|
356 | 388 | 'user_permission': {
|
357 | 389 | 'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
|
|
372 | 404 | EXPORT_DATA_FIELDS_IN_CARD_ORDER = False
|
373 | 405 |
|
374 | 406 | #Identify the usernames and duration (seconds) for which you want to cache the time wheel
|
375 |
| -CACHE_BY_USER = {'anonymous': 3600 * 24} |
| 407 | +CACHE_BY_USER = { |
| 408 | + "default": 3600 * 24, #24hrs |
| 409 | + "anonymous": 3600 * 24 #24hrs |
| 410 | + } |
| 411 | + |
376 | 412 | TILE_CACHE_TIMEOUT = 600 #seconds
|
377 | 413 | CLUSTER_DISTANCE_MAX = 5000 #meters
|
378 | 414 | GRAPH_MODEL_CACHE_TIMEOUT = None
|
|
443 | 479 | DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
444 | 480 |
|
445 | 481 | TILESERVER_URL = None
|
| 482 | +ENABLE_USER_SIGNUP = False |
| 483 | +ENABLE_PERSON_USER_SIGNUP = True |
446 | 484 |
|
447 | 485 | CELERY_BROKER_URL = "" # RabbitMQ --> "amqp://guest:guest@localhost", Redis --> "redis://localhost:6379/0"
|
448 | 486 | CELERY_ACCEPT_CONTENT = ['json']
|
449 | 487 | CELERY_RESULT_BACKEND = 'django-db' # Use 'django-cache' if you want to use your cache as your backend
|
450 | 488 | CELERY_TASK_SERIALIZER = 'json'
|
| 489 | +RABBITMQ_USER = os.getenv("RABBITMQ_USER") |
| 490 | +RABBITMQ_PASS = os.getenv("RABBITMQ_PASS") |
| 491 | +RABBITMQ_HOST = os.getenv("RABBITMQ_HOST") |
| 492 | + |
| 493 | + |
451 | 494 | CELERY_SEARCH_EXPORT_EXPIRES = 24 * 3600 # seconds
|
452 | 495 | CELERY_SEARCH_EXPORT_CHECK = 3600 # seconds
|
453 | 496 |
|
|
514 | 557 | # value and is not signed in with a user account then the request will not be allowed.
|
515 | 558 | RESTRICT_CELERY_EXPORT_FOR_ANONYMOUS_USER = False
|
516 | 559 |
|
| 560 | +# Dictionary containing any additional context items for customising email templates |
| 561 | +EXTRA_EMAIL_CONTEXT = { |
| 562 | + "salutation": _("Hi"), |
| 563 | + "expiration":(datetime.now() + timedelta(seconds=CELERY_SEARCH_EXPORT_EXPIRES)).strftime("%A, %d %B %Y") |
| 564 | +} |
| 565 | + |
517 | 566 | # see https://docs.djangoproject.com/en/1.9/topics/i18n/translation/#how-django-discovers-language-preference
|
518 | 567 | # to see how LocaleMiddleware tries to determine the user's language preference
|
519 | 568 | # (make sure to check your accept headers as they will override the LANGUAGE_CODE setting!)
|
|
0 commit comments