Skip to content

Commit 9e4ef90

Browse files
committed
fix: fix settings
1 parent 4d7c5cb commit 9e4ef90

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

manatee/settings.py

+51-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
Django settings for manatee project.
33
"""
44

5+
try:
6+
import tomllib
7+
except ImportError:
8+
from pip._vendor import tomli as tomllib
9+
510
import json
611
import os
712
import sys
813
import arches
914
import inspect
1015
import semantic_version
1116
from django.utils.translation import gettext_lazy as _
17+
from datetime import datetime, timedelta
1218

1319
try:
1420
from arches.settings import *
@@ -137,6 +143,7 @@
137143
PG_SUPERUSER = ""
138144
PG_SUPERUSER_PW = ""
139145

146+
# SECURITY WARNING: don't run with debug turned on in production!
140147
# from http://django-guardian.readthedocs.io/en/stable/configuration.html#anonymous-user-name
141148
ANONYMOUS_USER_NAME = None
142149

@@ -145,6 +152,7 @@
145152
SEARCH_THUMBNAILS = False
146153
# see http://elasticsearch-py.readthedocs.org/en/master/api.html#elasticsearch.Elasticsearch
147154
ELASTICSEARCH_HOSTS = [{"scheme": "https", "host": "localhost", "port": ELASTICSEARCH_HTTP_PORT}]
155+
DEBUG = False
148156

149157
ROOT_URLCONF = 'manatee.urls'
150158

@@ -210,6 +218,8 @@
210218
}
211219
}
212220

221+
SEARCH_THUMBNAILS = False
222+
213223
INSTALLED_APPS = (
214224
"webpack_loader",
215225
"django.contrib.admin",
@@ -255,13 +265,22 @@
255265
"arches.app.utils.middleware.SetAnonymousUser",
256266
# "silk.middleware.SilkyMiddleware",
257267
]
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+
258275

259276
STATICFILES_DIRS = build_staticfiles_dirs(
260277
root_dir=ROOT_DIR,
261278
app_root=APP_ROOT,
262279
arches_applications=ARCHES_APPLICATIONS,
263280
)
264281

282+
SERVE_STATIC = os.getenv("SERVE_STATIC", "True") == "True"
283+
265284
TEMPLATES = build_templates_config(
266285
root_dir=ROOT_DIR,
267286
debug=DEBUG,
@@ -294,6 +313,7 @@
294313
# when hosting Arches under a sub path set this value to the sub path eg : "/{sub_path}/"
295314
FORCE_SCRIPT_NAME = None
296315

316+
FORCE_USER_SIGNUP_EMAIL_AUTHENTICATION = False
297317
RESOURCE_IMPORT_LOG = os.path.join(APP_ROOT, 'logs', 'resource_import.log')
298318
DEFAULT_RESOURCE_IMPORT_USER = {'username': 'admin', 'userid': 1}
299319

@@ -311,6 +331,13 @@
311331
else:
312332
PERMISSION_FRAMEWORK = "arches_allow_with_credentials.ArchesAllowWithCredentialsFramework"
313333

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+
314341
LOGGING = {
315342
'version': 1,
316343
'disable_existing_loggers': False,
@@ -341,6 +368,10 @@
341368
}
342369
}
343370

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"
344375

345376
# Sets default max upload size to 15MB
346377
DATA_UPLOAD_MAX_MEMORY_SIZE = 15728640
@@ -351,7 +382,8 @@
351382
# For more info on configuring your cache: https://docs.djangoproject.com/en/2.2/topics/cache/
352383
CACHES = {
353384
'default': {
354-
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
385+
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
386+
"LOCATION": "unique-snowflake"
355387
},
356388
'user_permission': {
357389
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
@@ -372,7 +404,11 @@
372404
EXPORT_DATA_FIELDS_IN_CARD_ORDER = False
373405

374406
#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+
376412
TILE_CACHE_TIMEOUT = 600 #seconds
377413
CLUSTER_DISTANCE_MAX = 5000 #meters
378414
GRAPH_MODEL_CACHE_TIMEOUT = None
@@ -443,11 +479,18 @@
443479
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
444480

445481
TILESERVER_URL = None
482+
ENABLE_USER_SIGNUP = False
483+
ENABLE_PERSON_USER_SIGNUP = True
446484

447485
CELERY_BROKER_URL = "" # RabbitMQ --> "amqp://guest:guest@localhost", Redis --> "redis://localhost:6379/0"
448486
CELERY_ACCEPT_CONTENT = ['json']
449487
CELERY_RESULT_BACKEND = 'django-db' # Use 'django-cache' if you want to use your cache as your backend
450488
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+
451494
CELERY_SEARCH_EXPORT_EXPIRES = 24 * 3600 # seconds
452495
CELERY_SEARCH_EXPORT_CHECK = 3600 # seconds
453496

@@ -514,6 +557,12 @@
514557
# value and is not signed in with a user account then the request will not be allowed.
515558
RESTRICT_CELERY_EXPORT_FOR_ANONYMOUS_USER = False
516559

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+
517566
# see https://docs.djangoproject.com/en/1.9/topics/i18n/translation/#how-django-discovers-language-preference
518567
# to see how LocaleMiddleware tries to determine the user's language preference
519568
# (make sure to check your accept headers as they will override the LANGUAGE_CODE setting!)

0 commit comments

Comments
 (0)