summaryrefslogtreecommitdiffstats
path: root/localsettingsWSL.py
blob: 3a9a7931bfdb4de1de8a5647e86bf01a677feaf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import sys
import os
import urllib.parse
from pathlib import Path
"""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, or /javascript/ can be in
a system-wide location rather than just a local directory.

This file is included at the end of the main troggle/settings.py file so that
it overwrites defaults in that file.
"""

print(" * importing troggle/localsettings.py")

#-----------------------------------------------------------------
#  THINK before you push this to a repo
#  - have you checked that credentials.py is in .gitignore ?
#  - we don't want to have to change the expo system password !
#-----------------------------------------------------------------
# default values,  real secrets imported from credentials.py
# EXPOUSERPASS = "nnn:gggggg"
# EMAIL_HOST_PASSWORD = "insert-real-email-password-here"
from credentials import EXPOUSERPASS
from credentials import EMAIL_HOST_PASSWORD


EXPOFILESREMOTE = False # if True, then re-routes urls in expofiles to remote sever. Tests are then less accurate.
#SECURE_SSL_REDIRECT = True # breaks 7 tests in test suite 301 not 200 (or 302) and runserver fails completely

SERVERPORT = '8000' # not needed

# --------------------- MEDIA redirections BEGIN --------------------- 
#REPOS_ROOT_PATH  = '/mnt/d/CUCC-Expo/t37/'
REPOS_ROOT_PATH = Path(__file__).parent.parent
LIBDIR  =  REPOS_ROOT_PATH / 'lib' / 'python3.7' # should be finding this automatically: python --version etc.

TROGGLE_PATH = Path(__file__).parent
TEMPLATE_PATH     = TROGGLE_PATH / 'templates'
MEDIA_ROOT        = TROGGLE_PATH / 'media'
JSLIB_ROOT        = TROGGLE_PATH / 'media' / 'jslib' # used for CaveViewer JS utility

FILES = Path('/mnt/f/expofiles/')
EXPOFILES = Path('/mnt/f/expofiles/')
SURVEY_SCANS = EXPOFILES / 'surveyscans'
PHOTOS_ROOT = EXPOFILES / 'photos'

# 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/'

DIR_ROOT = ''#this should end in / if a value is given
URL_ROOT = '/'
# URL_ROOT = 'http://localhost:'+ SERVERPORT +'/'

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/') # used for CaveViewer JS utility

#STATIC_ROOT removed after merging content into MEDIA_ROOT. See urls.py & core/views/surveys.py
# --------------------- MEDIA redirections END --------------------- 

PUBLIC_SITE = True
DEBUG = True # Always keep this True, even when on public server. Otherwise NO USEFUL ERROR MESSAGES !

# executables:
CAVERN = 'cavern' # for parsing .svx files and producing .3d files
SURVEXPORT = 'survexport' # for parsing .3d files and producing .pos files

DATABASES = {
    'default': { 
        'ENGINE': 'django.db.backends.sqlite3', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME' : 'troggle.sqlite',
#        'NAME' : ':memory:',
        '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.
    }
}
# add in 358 when they don't make it crash horribly
NOTABLECAVESHREFS = [ "290", "291", "359", "264", "258", "204", "76", "107"]

PYTHON_PATH = REPOS_ROOT_PATH / 'troggle'
sys.path.append(os.fspath(REPOS_ROOT_PATH))
sys.path.append(os.fspath(PYTHON_PATH))

LOGFILE = PYTHON_PATH / 'troggle.log'
PYTHON_PATH = os.fspath(PYTHON_PATH)

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            TEMPLATE_PATH
        ],
        'OPTIONS': {
            'debug': 'DEBUG',
            '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
                'django.template.context_processors.debug',
                #'django.template.context_processors.request', # copy of current request, added in trying to make csrf work
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',  # includes a variable MEDIA_URL
                'django.template.context_processors.static', # includes a variable STATIC_URL
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
            ],
            'loaders': [
                'django.template.loaders.filesystem.Loader', # default lcation is troggle/templates/
                'django.template.loaders.app_directories.Loader', # needed for admin 'app' 
           ]
       },
    },
]

# Passwords are loaded from credentials.py by settings.py
EXPOUSERPASS = "nnn:gggggg" # overwritten by loading from credentials.py 
EMAIL_HOST_PASSWORD = "insert-real-email-password-here" # overwritten by loading from credentials.py

EXPOUSER = 'expo'
EXPOUSER_EMAIL = 'philip.sargent@gmail.com'

EMAIL_HOST = "smtp-auth.mythic-beasts.com"
EMAIL_HOST_USER = "django-test@klebos.net" # Philip Sargent really
EMAIL_PORT=587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'django-test@klebos.net'

SURVEX_DATA = REPOS_ROOT_PATH / "loser"
TUNNEL_DATA = REPOS_ROOT_PATH / "drawings"
THREEDCACHEDIR  =  REPOS_ROOT_PATH / 'expowebcache' / '3d'

EXPOWEB = REPOS_ROOT_PATH / "expoweb" 
SURVEYS = REPOS_ROOT_PATH
CAVEDESCRIPTIONS        = EXPOWEB / "cave_data"
ENTRANCEDESCRIPTIONS    = EXPOWEB / "entrance_data"
EXPOWEB_URL = ''
SURVEYS_URL = '/survey_scans/'

# Sanitise these to be strings as all other code is expecting strings
# and we have not made the change to pathlib Path type in the other localsettings-* variants yet.
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)
TEMPLATE_PATH   = os.fspath(TROGGLE_PATH)
MEDIA_ROOT      = os.fspath(MEDIA_ROOT)
JSLIB_ROOT      = os.fspath(JSLIB_ROOT)
JSLIB_ROOT      = os.fspath(JSLIB_ROOT)
JSLIB_ROOT      = os.fspath(JSLIB_ROOT)
SURVEY_SCANS    = os.fspath(SURVEY_SCANS)
print(" + finished importing troggle/localsettings.py")