2020-06-20 17:19:50 +01:00
|
|
|
import os
|
2023-01-19 20:47:26 +00:00
|
|
|
import sys
|
2020-06-20 17:19:50 +01:00
|
|
|
import urllib.parse
|
2021-03-24 17:32:45 +00:00
|
|
|
from pathlib import Path
|
2023-01-19 20:47:26 +00:00
|
|
|
|
2020-07-18 16:23:54 +01:00
|
|
|
"""Settings for a troggle installation which may vary among different
|
|
|
|
installations: for development or deployment, in a docker image or
|
|
|
|
python virtual environment (venv), on ubuntu, debian or in Windows
|
|
|
|
System for Linux (WSL), on the main server or in the potato hut,
|
|
|
|
using SQLite or mariaDB.
|
|
|
|
|
|
|
|
It sets the directory locations for the major parts of the system so
|
2021-04-02 23:21:23 +01:00
|
|
|
that e.g. expofiles can be on a different filesystem, or /javascript/ can be in
|
|
|
|
a system-wide location rather than just a local directory.
|
2020-07-18 16:23:54 +01:00
|
|
|
|
|
|
|
This file is included at the end of the main troggle/settings.py file so that
|
|
|
|
it overwrites defaults in that file.
|
2021-04-06 00:49:09 +01:00
|
|
|
|
2022-02-25 18:33:34 +00:00
|
|
|
Read https://realpython.com/python-pathlib/
|
2021-04-06 00:49:09 +01:00
|
|
|
Read https://adamj.eu/tech/2020/03/16/use-pathlib-in-your-django-project/
|
2020-07-18 16:23:54 +01:00
|
|
|
"""
|
2020-06-20 17:19:50 +01:00
|
|
|
|
|
|
|
print(" * importing troggle/localsettings.py")
|
|
|
|
|
2020-06-24 01:57:20 +01:00
|
|
|
#-----------------------------------------------------------------
|
|
|
|
# THINK before you push this to a repo
|
2021-04-01 02:50:30 +01:00
|
|
|
# - have you checked that credentials.py is in .gitignore ?
|
2020-06-24 01:57:20 +01:00
|
|
|
# - we don't want to have to change the expo system password !
|
|
|
|
#-----------------------------------------------------------------
|
2021-04-03 00:33:55 +01:00
|
|
|
# default values, real secrets imported from credentials.py
|
2020-06-24 01:57:20 +01:00
|
|
|
|
2021-10-23 19:07:16 +01:00
|
|
|
SECRET_KEY = "real-SECRET_KEY--imported-from-localsettings.py"
|
|
|
|
EXPOUSERPASS = "nnn:gggggg - real-expo-password---imported-from-localsettings.py"
|
2022-04-12 20:42:36 +01:00
|
|
|
EXPOADMINUSERPASS = "gggggg:nnn - real-expo-password---imported-from-localsettings.py"
|
2021-10-23 19:07:16 +01:00
|
|
|
EMAIL_HOST_PASSWORD = "real-email-password---imported-from-localsettings.py"
|
2021-04-03 00:33:55 +01:00
|
|
|
|
2022-06-25 18:01:43 +01:00
|
|
|
EXPOFILESREMOTE = False # if True, then re-routes urls in expofiles to remote sever. Tests are then less accurate.
|
2021-03-24 17:32:45 +00:00
|
|
|
#SECURE_SSL_REDIRECT = True # breaks 7 tests in test suite 301 not 200 (or 302) and runserver fails completely
|
2021-03-26 13:51:00 +00:00
|
|
|
|
2021-04-02 23:21:23 +01:00
|
|
|
SERVERPORT = '8000' # not needed
|
|
|
|
|
2022-02-25 18:33:34 +00:00
|
|
|
PV = "python" + str(sys.version_info.major) + "." + str(sys.version_info.minor)
|
|
|
|
|
|
|
|
# Troggle does a lot of file-handling. This is very error-prone when using primitive methods,
|
|
|
|
# so we use pathlib which has been standard since python 3.4
|
2022-04-06 19:07:43 +01:00
|
|
|
# If pathlib is new to you, you will need to read https://realpython.com/python-pathlib/
|
2022-02-25 18:33:34 +00:00
|
|
|
|
2021-03-22 02:26:46 +00:00
|
|
|
# --------------------- MEDIA redirections BEGIN ---------------------
|
2022-02-25 18:33:34 +00:00
|
|
|
REPOS_ROOT_PATH = Path(__file__).parent.parent
|
|
|
|
LIBDIR = REPOS_ROOT_PATH / 'lib' / PV
|
2022-12-23 22:13:11 +00:00
|
|
|
#LIBDIR = REPOS_ROOT_PATH / 'lib' / 'python3.9'
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2021-03-24 17:32:45 +00:00
|
|
|
TROGGLE_PATH = Path(__file__).parent
|
2021-04-02 23:21:23 +01:00
|
|
|
TEMPLATE_PATH = TROGGLE_PATH / 'templates'
|
|
|
|
MEDIA_ROOT = TROGGLE_PATH / 'media'
|
|
|
|
JSLIB_ROOT = TROGGLE_PATH / 'media' / 'jslib' # used for CaveViewer JS utility
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2022-04-06 19:07:43 +01:00
|
|
|
#FILES = Path('/mnt/d/expofiles/')
|
2022-12-23 22:13:11 +00:00
|
|
|
EXPOFILES = REPOS_ROOT_PATH / "expofiles"
|
|
|
|
|
2022-06-25 18:01:43 +01:00
|
|
|
SCANS_ROOT = EXPOFILES / 'surveyscans'
|
2021-04-01 02:50:30 +01:00
|
|
|
PHOTOS_ROOT = EXPOFILES / 'photos'
|
2022-03-13 11:26:29 +00:00
|
|
|
PHOTOS_YEAR = "2022"
|
2021-04-01 02:50:30 +01:00
|
|
|
|
2021-03-22 02:26:46 +00:00
|
|
|
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
|
|
# trailing slash if there is a path component (optional in other cases).
|
|
|
|
MEDIA_URL = '/site-media/'
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2022-12-23 22:13:11 +00:00
|
|
|
DIR_ROOT = Path('') #this should end in / if a value is given
|
2021-04-01 02:50:30 +01:00
|
|
|
URL_ROOT = '/'
|
2021-04-02 23:21:23 +01:00
|
|
|
# URL_ROOT = 'http://localhost:'+ SERVERPORT +'/'
|
2021-03-24 17:32:45 +00:00
|
|
|
|
2022-06-25 18:01:43 +01:00
|
|
|
#Note that these constants are not actually used in urls.py, they should be..
|
2022-12-23 22:13:11 +00:00
|
|
|
# and they all need to end with / so using 'Path' doesn't work..
|
|
|
|
MEDIA_URL = Path(URL_ROOT , '/site_media/')
|
|
|
|
PHOTOS_URL = Path(URL_ROOT , '/photos/')
|
2021-03-24 17:32:45 +00:00
|
|
|
|
|
|
|
|
2022-12-23 22:13:11 +00:00
|
|
|
STATIC_URL = Path(URL_ROOT , '/static/') # used by Django admin pages. Do not delete.
|
|
|
|
JSLIB_URL = Path(URL_ROOT , '/javascript/') # used for CaveViewer JS utility
|
2021-03-24 17:32:45 +00:00
|
|
|
|
2021-03-31 21:51:17 +01:00
|
|
|
#STATIC_ROOT removed after merging content into MEDIA_ROOT. See urls.py & core/views/surveys.py
|
2021-03-22 02:26:46 +00:00
|
|
|
# --------------------- MEDIA redirections END ---------------------
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2020-07-19 01:23:07 +01:00
|
|
|
PUBLIC_SITE = True
|
2021-03-26 02:01:29 +00:00
|
|
|
DEBUG = True # Always keep this True, even when on public server. Otherwise NO USEFUL ERROR MESSAGES !
|
2021-04-13 01:37:42 +01:00
|
|
|
CACHEDPAGES = True # experimental page cache for a handful of page types
|
2020-06-20 17:19:50 +01:00
|
|
|
|
|
|
|
# executables:
|
2021-03-26 13:51:00 +00:00
|
|
|
CAVERN = 'cavern' # for parsing .svx files and producing .3d files
|
|
|
|
SURVEXPORT = 'survexport' # for parsing .3d files and producing .pos files
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2022-06-25 18:01:43 +01:00
|
|
|
DBSQLITE = {
|
2020-06-20 17:19:50 +01:00
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.sqlite3', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
2022-12-23 22:13:11 +00:00
|
|
|
'NAME' : '/home/philip/p11d5/troggle.sqlite',
|
2020-06-20 23:08:34 +01:00
|
|
|
# 'NAME' : ':memory:',
|
2020-06-20 17:19:50 +01:00
|
|
|
'USER' : 'expo', # Not used with sqlite3.
|
|
|
|
'PASSWORD' : 'sekrit', # Not used with sqlite3.
|
|
|
|
'HOST' : '', # Set to empty string for localhost. Not used with sqlite3.
|
|
|
|
'PORT' : '', # Set to empty string for default. Not used with sqlite3.
|
|
|
|
}
|
|
|
|
}
|
2022-06-25 18:01:43 +01:00
|
|
|
DBMARIADB = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.mysql', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
|
|
|
'NAME' : 'troggle', # Or path to database file if using sqlite3.
|
|
|
|
'USER' : 'expo',
|
|
|
|
'PASSWORD' : 'my-secret-password-schwatzmooskogel',
|
|
|
|
'HOST' : '', # Set to empty string for localhost. Not used with sqlite3.
|
|
|
|
'PORT' : '', # Set to empty string for default. Not used with sqlite3.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# default database for me is squlite
|
|
|
|
DBSWITCH = "sqlite"
|
|
|
|
|
|
|
|
if DBSWITCH == "sqlite":
|
|
|
|
DATABASES = DBSQLITE
|
|
|
|
if DBSWITCH == "mariadb":
|
|
|
|
DATABASES = DBMARIADB
|
|
|
|
|
2021-03-26 02:01:29 +00:00
|
|
|
NOTABLECAVESHREFS = [ "290", "291", "359", "264", "258", "204", "76", "107"]
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2021-03-24 17:32:45 +00:00
|
|
|
PYTHON_PATH = REPOS_ROOT_PATH / 'troggle'
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2021-03-24 17:32:45 +00:00
|
|
|
LOGFILE = PYTHON_PATH / 'troggle.log'
|
2022-12-23 22:13:11 +00:00
|
|
|
|
2020-06-20 17:19:50 +01:00
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
'DIRS': [
|
2021-03-24 17:32:45 +00:00
|
|
|
TEMPLATE_PATH
|
2020-06-20 17:19:50 +01:00
|
|
|
],
|
|
|
|
'OPTIONS': {
|
|
|
|
'debug': 'DEBUG',
|
2021-04-01 02:50:30 +01:00
|
|
|
'context_processors': [
|
|
|
|
# django.template.context_processors.csrf, # is always enabled and cannot be removed, sets csrf_token
|
|
|
|
'django.contrib.auth.context_processors.auth', # knowledge of logged-on user & permissions
|
2021-04-26 18:42:10 +01:00
|
|
|
'core.context.troggle_context', # in core/troggle.py - only used in expedition.html
|
2020-06-20 17:19:50 +01:00
|
|
|
'django.template.context_processors.debug',
|
|
|
|
'django.template.context_processors.i18n',
|
2021-04-01 02:50:30 +01:00
|
|
|
'django.template.context_processors.media', # includes a variable MEDIA_URL
|
2022-02-25 18:33:34 +00:00
|
|
|
'django.template.context_processors.static', # includes a variable STATIC_URL used by admin pages
|
2020-06-20 17:19:50 +01:00
|
|
|
'django.template.context_processors.tz',
|
2021-04-26 18:42:10 +01:00
|
|
|
'django.template.context_processors.request', # must be enabled in DjangoTemplates (TEMPLATES) in order to use the admin navigation sidebar.
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
2020-06-20 17:19:50 +01:00
|
|
|
],
|
|
|
|
'loaders': [
|
2021-04-02 23:21:23 +01:00
|
|
|
'django.template.loaders.filesystem.Loader', # default lcation is troggle/templates/
|
|
|
|
'django.template.loaders.app_directories.Loader', # needed for admin 'app'
|
2020-06-20 17:19:50 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
EXPOUSER = 'expo'
|
|
|
|
EXPOUSER_EMAIL = 'philip.sargent@gmail.com'
|
2021-04-06 00:49:09 +01:00
|
|
|
EXPOADMINUSER = 'expoadmin'
|
|
|
|
EXPOADMINUSER_EMAIL = 'philip.sargent@gmail.com'
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2021-04-01 02:50:30 +01:00
|
|
|
EMAIL_HOST = "smtp-auth.mythic-beasts.com"
|
|
|
|
EMAIL_HOST_USER = "django-test@klebos.net" # Philip Sargent really
|
2020-06-20 17:19:50 +01:00
|
|
|
EMAIL_PORT=587
|
|
|
|
EMAIL_USE_TLS = True
|
2021-04-01 02:50:30 +01:00
|
|
|
DEFAULT_FROM_EMAIL = 'django-test@klebos.net'
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2021-03-24 17:32:45 +00:00
|
|
|
SURVEX_DATA = REPOS_ROOT_PATH / "loser"
|
2021-04-26 18:42:10 +01:00
|
|
|
DRAWINGS_DATA = REPOS_ROOT_PATH / "drawings"
|
2021-03-26 02:01:29 +00:00
|
|
|
EXPOWEB = REPOS_ROOT_PATH / "expoweb"
|
2022-12-23 22:13:11 +00:00
|
|
|
|
2021-03-24 17:32:45 +00:00
|
|
|
CAVEDESCRIPTIONS = EXPOWEB / "cave_data"
|
|
|
|
ENTRANCEDESCRIPTIONS = EXPOWEB / "entrance_data"
|
2020-06-20 17:19:50 +01:00
|
|
|
EXPOWEB_URL = ''
|
2022-07-27 21:23:43 +01:00
|
|
|
# SCANS_URL = '/survey_scans/' # defunct, removed.
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2021-03-26 02:01:29 +00:00
|
|
|
# Sanitise these to be strings as all other code is expecting strings
|
2021-03-26 13:51:00 +00:00
|
|
|
# and we have not made the change to pathlib Path type in the other localsettings-* variants yet.
|
2022-12-23 22:13:11 +00:00
|
|
|
# CAVEDESCRIPTIONS = str(CAVEDESCRIPTIONS)
|
|
|
|
# ENTRANCEDESCRIPTIONS = str(ENTRANCEDESCRIPTIONS)
|
|
|
|
# LOGFILE = str(LOGFILE)
|
|
|
|
# EXPOWEB = str(EXPOWEB)
|
|
|
|
# DRAWINGS_DATA = str(DRAWINGS_DATA)
|
|
|
|
# SURVEX_DATA = str(SURVEX_DATA)
|
|
|
|
# TEMPLATE_PATH = str(TROGGLE_PATH)
|
|
|
|
# MEDIA_ROOT = str(MEDIA_ROOT)
|
|
|
|
# JSLIB_ROOT = str(JSLIB_ROOT)
|
|
|
|
# SCANS_ROOT = str(SCANS_ROOT)
|
|
|
|
# EXPOFILES = str(EXPOFILES)
|
|
|
|
# PHOTOS_ROOT = str(PHOTOS_ROOT)
|
|
|
|
STATIC_URL = str(STATIC_URL) +"/"
|
|
|
|
MEDIA_URL = str(MEDIA_URL) +"/"
|
|
|
|
# PYTHON_PATH = str(PYTHON_PATH)
|
|
|
|
# REPOS_ROOT_PATH = str(REPOS_ROOT_PATH)
|
|
|
|
sys.path.append(str(REPOS_ROOT_PATH))
|
|
|
|
sys.path.append(str(PYTHON_PATH))
|