2020-06-20 17:19:50 +01:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import urllib.parse
|
2021-03-24 17:32:45 +00:00
|
|
|
from pathlib import Path
|
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
|
|
|
|
that e.g. expofiles can be on a different filesystem.
|
|
|
|
|
|
|
|
This file is included at the end of the main troggle/settings.py file so that
|
|
|
|
it overwrites defaults in that file.
|
|
|
|
"""
|
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-01 02:50:30 +01:00
|
|
|
# default values, then get overwritten by real secrets
|
|
|
|
EXPOUSERPASS = "nnn:gggggg"
|
|
|
|
EMAIL_HOST_PASSWORD = "insert-real-email-password-here"
|
|
|
|
from credentials import EXPOUSERPASS
|
|
|
|
from credentials import EMAIL_HOST_PASSWORD
|
2020-06-24 01:57:20 +01:00
|
|
|
|
2020-08-02 23:53:35 +01:00
|
|
|
SERVERPORT = '8000'
|
2021-04-01 02:50:30 +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-03-22 02:26:46 +00:00
|
|
|
# --------------------- MEDIA redirections BEGIN ---------------------
|
|
|
|
#REPOS_ROOT_PATH = '/mnt/d/CUCC-Expo/t37/'
|
2021-03-24 17:32:45 +00:00
|
|
|
REPOS_ROOT_PATH = Path(__file__).parent.parent
|
|
|
|
LIBDIR = REPOS_ROOT_PATH / 'lib' / 'python3.7'
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2021-03-24 17:32:45 +00:00
|
|
|
TROGGLE_PATH = Path(__file__).parent
|
|
|
|
TEMPLATE_PATH = os.fspath(TROGGLE_PATH / 'templates')
|
|
|
|
MEDIA_ROOT = os.fspath(TROGGLE_PATH / 'media')
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2021-04-01 02:50:30 +01:00
|
|
|
FILES = Path('/mnt/f/expofiles/')
|
|
|
|
EXPOFILES = Path('/mnt/f/expofiles/')
|
|
|
|
SURVEY_SCANS = EXPOFILES / 'surveyscans'
|
|
|
|
PHOTOS_ROOT = EXPOFILES / 'photos'
|
|
|
|
|
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
|
|
|
|
2021-03-24 17:32:45 +00:00
|
|
|
DIR_ROOT = ''#this should end in / if a value is given
|
2021-04-01 02:50:30 +01:00
|
|
|
URL_ROOT = '/'
|
|
|
|
URL_ROOT = 'http://localhost:'+ SERVERPORT +'/'
|
2021-03-24 17:32:45 +00:00
|
|
|
|
|
|
|
MEDIA_URL = urllib.parse.urljoin(URL_ROOT , '/site_media/')
|
|
|
|
SURVEYS_URL = urllib.parse.urljoin(URL_ROOT , '/survey_scans/')
|
|
|
|
PHOTOS_URL = urllib.parse.urljoin(URL_ROOT , '/photos/')
|
|
|
|
SVX_URL = urllib.parse.urljoin(URL_ROOT , '/survex/')
|
|
|
|
|
|
|
|
|
|
|
|
STATIC_URL = urllib.parse.urljoin(URL_ROOT , '/static/') # used by Django admin pages. Do not delete.
|
|
|
|
JSLIB_URL = urllib.parse.urljoin(URL_ROOT , '/javascript/') # always fails, try to revive it ?
|
|
|
|
|
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 !
|
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
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.sqlite3', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
|
|
|
'NAME' : '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.
|
|
|
|
}
|
|
|
|
}
|
2021-03-26 02:01:29 +00:00
|
|
|
# add in 358 when they don't make it crash horribly
|
|
|
|
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'
|
|
|
|
sys.path.append(os.fspath(REPOS_ROOT_PATH))
|
|
|
|
sys.path.append(os.fspath(PYTHON_PATH))
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2021-03-24 17:32:45 +00:00
|
|
|
LOGFILE = PYTHON_PATH / 'troggle.log'
|
|
|
|
PYTHON_PATH = os.fspath(PYTHON_PATH)
|
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
|
|
|
|
'core.context.troggle_context', # in core/troggle.py
|
2020-06-20 17:19:50 +01:00
|
|
|
'django.template.context_processors.debug',
|
2021-04-01 02:50:30 +01:00
|
|
|
#'django.template.context_processors.request', # copy of current request, added in trying to make csrf work
|
2020-06-20 17:19:50 +01:00
|
|
|
'django.template.context_processors.i18n',
|
2021-04-01 02:50:30 +01:00
|
|
|
'django.template.context_processors.media', # includes a variable MEDIA_URL
|
|
|
|
'django.template.context_processors.static', # includes a variable STATIC_URL
|
2020-06-20 17:19:50 +01:00
|
|
|
'django.template.context_processors.tz',
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
|
|
|
],
|
|
|
|
'loaders': [
|
|
|
|
'django.template.loaders.filesystem.Loader',
|
2021-04-01 02:50:30 +01:00
|
|
|
'django.template.loaders.app_directories.Loader', #For each app, inc admin, in INSTALLED_APPS, loader looks for /templates
|
2021-03-26 02:01:29 +00:00
|
|
|
# insert your own TEMPLATE_LOADERS here
|
2020-06-20 17:19:50 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
EXPOUSER = 'expo'
|
2021-04-01 02:50:30 +01:00
|
|
|
# EXPOUSERPASS = "nnn:gggggg" # loaded from credentials.py
|
2020-06-20 17:19:50 +01:00
|
|
|
EXPOUSER_EMAIL = 'philip.sargent@gmail.com'
|
|
|
|
|
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
|
|
|
|
# EMAIL_HOST_PASSWORD = "insert-real-email-password-here" # loaded from credentials.py
|
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"
|
|
|
|
TUNNEL_DATA = REPOS_ROOT_PATH / "drawings"
|
|
|
|
THREEDCACHEDIR = REPOS_ROOT_PATH / 'expowebcache' / '3d'
|
2020-06-20 17:19:50 +01:00
|
|
|
|
2021-03-26 02:01:29 +00:00
|
|
|
EXPOWEB = REPOS_ROOT_PATH / "expoweb"
|
2020-06-20 17:19:50 +01:00
|
|
|
SURVEYS = REPOS_ROOT_PATH
|
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 = ''
|
|
|
|
SURVEYS_URL = '/survey_scans/'
|
|
|
|
|
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.
|
2021-03-26 02:01:29 +00:00
|
|
|
CAVEDESCRIPTIONS = os.fspath(CAVEDESCRIPTIONS)
|
|
|
|
ENTRANCEDESCRIPTIONS = os.fspath(ENTRANCEDESCRIPTIONS)
|
|
|
|
LOGFILE = os.fspath(LOGFILE)
|
|
|
|
SURVEYS = os.fspath(SURVEYS)
|
|
|
|
EXPOWEB = os.fspath(EXPOWEB)
|
|
|
|
THREEDCACHEDIR = os.fspath(THREEDCACHEDIR)
|
|
|
|
TUNNEL_DATA = os.fspath(TUNNEL_DATA)
|
|
|
|
SURVEX_DATA = os.fspath(SURVEX_DATA)
|
|
|
|
REPOS_ROOT_PATH = os.fspath(REPOS_ROOT_PATH)
|
2020-06-20 17:19:50 +01:00
|
|
|
print(" + finished importing troggle/localsettings.py")
|