-
Notifications
You must be signed in to change notification settings - Fork 0
/
local_settings.py.sample
393 lines (356 loc) · 13 KB
/
local_settings.py.sample
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# -*- coding: utf-8 -*-
#########################################################################
#
# Copyright (C) 2018 OSGeo
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################
""" There are 3 ways to override GeoNode settings:
1. Using environment variables, if your changes to GeoNode are minimal.
2. Creating a downstream project, if you are doing a lot of customization.
3. Override settings in a local_settings.py file, legacy.
"""
import ast
import os
from urlparse import urlparse, urlunparse
from geonode.settings import *
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
MEDIA_ROOT = os.getenv('MEDIA_ROOT', os.path.join(PROJECT_ROOT, "uploaded"))
STATIC_ROOT = os.getenv('STATIC_ROOT',
os.path.join(PROJECT_ROOT, "static_root")
)
# SECRET_KEY = '************************'
# Make this unique, and don't share it with anybody.
SECRET_KEY = os.getenv('SECRET_KEY', "jw(u14+8nx2r$+s$%si9doa_3uob5$m!y5_!z+7m!z!n(*q7m2")
# per-deployment settings should go here
SITE_HOST_NAME = os.getenv('SITE_HOST_NAME', 'localhost')
SITE_HOST_PORT = os.getenv('SITE_HOST_PORT', None)
_default_siteurl = "http://%s:%s/" % (SITE_HOST_NAME, SITE_HOST_PORT) if SITE_HOST_PORT else "http://%s/" % SITE_HOST_NAME
SITEURL = os.getenv('SITEURL', _default_siteurl)
# we need hostname for deployed
_surl = urlparse(SITEURL)
HOSTNAME = _surl.hostname
# add trailing slash to site url. geoserver url will be relative to this
if not SITEURL.endswith('/'):
SITEURL = '{}/'.format(SITEURL)
try:
# try to parse python notation, default in dockerized env
ALLOWED_HOSTS = ast.literal_eval(os.getenv('ALLOWED_HOSTS'))
except ValueError:
# fallback to regular list of values separated with misc chars
ALLOWED_HOSTS = [HOSTNAME, 'localhost', 'django', 'geonode'] if os.getenv('ALLOWED_HOSTS') is None \
else re.split(r' *[,|:|;] *', os.getenv('ALLOWED_HOSTS'))
TIME_ZONE = 'UTC'
# Login and logout urls override
LOGIN_URL = os.getenv('LOGIN_URL', '{}account/login/'.format(SITEURL))
LOGOUT_URL = os.getenv('LOGOUT_URL', '{}account/logout/'.format(SITEURL))
ACCOUNT_LOGIN_REDIRECT_URL = os.getenv('LOGIN_REDIRECT_URL', SITEURL)
ACCOUNT_LOGOUT_REDIRECT_URL = os.getenv('LOGOUT_REDIRECT_URL', SITEURL)
# Backend
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'geonode',
'USER': 'geonode',
'PASSWORD': 'geonode',
'HOST': 'localhost',
'PORT': '5432',
'CONN_TOUT': 900,
},
# vector datastore for uploads
'datastore': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
# 'ENGINE': '', # Empty ENGINE name disables
'NAME': 'geonode_data',
'USER': 'geonode',
'PASSWORD': 'geonode',
'HOST': 'localhost',
'PORT': '5432',
'CONN_TOUT': 900,
}
}
GEOSERVER_LOCATION = os.getenv(
'GEOSERVER_LOCATION', 'http://localhost:8080/geoserver/'
)
GEOSERVER_PUBLIC_HOST = os.getenv(
'GEOSERVER_PUBLIC_HOST', SITE_HOST_NAME
)
GEOSERVER_PUBLIC_PORT = os.getenv(
'GEOSERVER_PUBLIC_PORT', 8080
)
_default_public_location = 'http://{}:{}/geoserver/'.format(GEOSERVER_PUBLIC_HOST, GEOSERVER_PUBLIC_PORT) if GEOSERVER_PUBLIC_PORT else 'http://{}/geoserver/'.format(GEOSERVER_PUBLIC_HOST)
GEOSERVER_WEB_UI_LOCATION = os.getenv(
'GEOSERVER_WEB_UI_LOCATION', GEOSERVER_LOCATION
)
GEOSERVER_PUBLIC_LOCATION = os.getenv(
'GEOSERVER_PUBLIC_LOCATION', _default_public_location
)
OGC_SERVER_DEFAULT_USER = os.getenv(
'GEOSERVER_ADMIN_USER', 'admin'
)
OGC_SERVER_DEFAULT_PASSWORD = os.getenv(
'GEOSERVER_ADMIN_PASSWORD', 'geoserver'
)
# OGC (WMS/WFS/WCS) Server Settings
OGC_SERVER = {
'default': {
'BACKEND': 'geonode.geoserver',
'LOCATION': GEOSERVER_LOCATION,
'WEB_UI_LOCATION': GEOSERVER_WEB_UI_LOCATION,
'LOGIN_ENDPOINT': 'j_spring_oauth2_geonode_login',
'LOGOUT_ENDPOINT': 'j_spring_oauth2_geonode_logout',
# PUBLIC_LOCATION needs to be kept like this because in dev mode
# the proxy won't work and the integration tests will fail
# the entire block has to be overridden in the local_settings
'PUBLIC_LOCATION': GEOSERVER_PUBLIC_LOCATION,
'USER': OGC_SERVER_DEFAULT_USER,
'PASSWORD': OGC_SERVER_DEFAULT_PASSWORD,
'MAPFISH_PRINT_ENABLED': True,
'PRINT_NG_ENABLED': True,
'GEONODE_SECURITY_ENABLED': True,
'GEOFENCE_SECURITY_ENABLED': True,
'WMST_ENABLED': False,
'BACKEND_WRITE_ENABLED': True,
'WPS_ENABLED': False,
'LOG_FILE': '%s/geoserver/data/logs/geoserver.log' % os.path.abspath(os.path.join(PROJECT_ROOT, os.pardir)),
# Set to dictionary identifier of database containing spatial data in DATABASES dictionary to enable
'DATASTORE': 'datastore',
'TIMEOUT': int(os.getenv('OGC_REQUEST_TIMEOUT', '5')),
'MAX_RETRIES': int(os.getenv('OGC_REQUEST_MAX_RETRIES', '5')),
'BACKOFF_FACTOR': float(os.getenv('OGC_REQUEST_BACKOFF_FACTOR', '0.3')),
'POOL_MAXSIZE': int(os.getenv('OGC_REQUEST_POOL_MAXSIZE', '10')),
'POOL_CONNECTIONS': int(os.getenv('OGC_REQUEST_POOL_CONNECTIONS', '10')),
}
}
# WARNING: Map Editing is affected by this. GeoExt Configuration is cached for 5 minutes
# CACHES = {
# 'default': {
# 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
# 'LOCATION': '/var/tmp/django_cache',
# }
# }
# If you want to enable Mosaics use the following configuration
UPLOADER = {
# 'BACKEND': 'geonode.rest',
'BACKEND': 'geonode.importer',
'OPTIONS': {
'TIME_ENABLED': True,
'MOSAIC_ENABLED': False,
},
'SUPPORTED_CRS': [
'EPSG:4326',
'EPSG:3785',
'EPSG:3857',
'EPSG:32647',
'EPSG:32736'
],
'SUPPORTED_EXT': [
'.shp',
'.csv',
'.kml',
'.kmz',
'.json',
'.geojson',
'.tif',
'.tiff',
'.geotiff',
'.gml',
'.xml'
]
}
# CSW settings
CATALOGUE = {
'default': {
# The underlying CSW implementation
# default is pycsw in local mode (tied directly to GeoNode Django DB)
'ENGINE': 'geonode.catalogue.backends.pycsw_local',
# pycsw in non-local mode
# 'ENGINE': 'geonode.catalogue.backends.pycsw_http',
# GeoNetwork opensource
# 'ENGINE': 'geonode.catalogue.backends.geonetwork',
# deegree and others
# 'ENGINE': 'geonode.catalogue.backends.generic',
# The FULLY QUALIFIED base url to the CSW instance for this GeoNode
'URL': urljoin(SITEURL, '/catalogue/csw'),
# 'URL': 'http://localhost:8080/geonetwork/srv/en/csw',
# 'URL': 'http://localhost:8080/deegree-csw-demo-3.0.4/services',
# login credentials (for GeoNetwork)
# 'USER': 'admin',
# 'PASSWORD': 'admin',
# 'ALTERNATES_ONLY': True,
}
}
# pycsw settings
PYCSW = {
# pycsw configuration
'CONFIGURATION': {
# uncomment / adjust to override server config system defaults
# 'server': {
# 'maxrecords': '10',
# 'pretty_print': 'true',
# 'federatedcatalogues': 'http://catalog.data.gov/csw'
# },
'server': {
'home': '.',
'url': CATALOGUE['default']['URL'],
'encoding': 'UTF-8',
'language': LANGUAGE_CODE,
'maxrecords': '20',
'pretty_print': 'true',
# 'domainquerytype': 'range',
'domaincounts': 'true',
'profiles': 'apiso,ebrim',
},
'manager': {
# authentication/authorization is handled by Django
'transactions': 'false',
'allowed_ips': '*',
# 'csw_harvest_pagesize': '10',
},
'metadata:main': {
'identification_title': 'GeoNode Catalogue',
'identification_abstract': 'GeoNode is an open source platform' \
' that facilitates the creation, sharing, and collaborative use' \
' of geospatial data',
'identification_keywords': 'sdi, catalogue, discovery, metadata,' \
' GeoNode',
'identification_keywords_type': 'theme',
'identification_fees': 'None',
'identification_accessconstraints': 'None',
'provider_name': 'Organization Name',
'provider_url': SITEURL,
'contact_name': 'Lastname, Firstname',
'contact_position': 'Position Title',
'contact_address': 'Mailing Address',
'contact_city': 'City',
'contact_stateorprovince': 'Administrative Area',
'contact_postalcode': 'Zip or Postal Code',
'contact_country': 'Country',
'contact_phone': '+xx-xxx-xxx-xxxx',
'contact_fax': '+xx-xxx-xxx-xxxx',
'contact_email': 'Email Address',
'contact_url': 'Contact URL',
'contact_hours': 'Hours of Service',
'contact_instructions': 'During hours of service. Off on ' \
'weekends.',
'contact_role': 'pointOfContact',
},
'metadata:inspire': {
'enabled': 'true',
'languages_supported': 'eng,gre',
'default_language': 'eng',
'date': 'YYYY-MM-DD',
'gemet_keywords': 'Utility and governmental services',
'conformity_service': 'notEvaluated',
'contact_name': 'Organization Name',
'contact_email': 'Email Address',
'temp_extent': 'YYYY-MM-DD/YYYY-MM-DD',
}
}
}
MAPBOX_ACCESS_TOKEN = os.environ.get('MAPBOX_ACCESS_TOKEN', None)
BING_API_KEY = os.environ.get('BING_API_KEY', None)
GOOGLE_API_KEY = os.environ.get('GOOGLE_API_KEY', None)
MAP_BASELAYERS = [{
"source": {"ptype": "gxp_olsource"},
"type": "OpenLayers.Layer",
"args": ["No background"],
"name": "background",
"visibility": False,
"fixed": True,
"group":"background"
},
# {
# "source": {"ptype": "gxp_olsource"},
# "type": "OpenLayers.Layer.XYZ",
# "title": "TEST TILE",
# "args": ["TEST_TILE", "http://test_tiles/tiles/${z}/${x}/${y}.png"],
# "name": "background",
# "attribution": "© TEST TILE",
# "visibility": False,
# "fixed": True,
# "group":"background"
# },
{
"source": {"ptype": "gxp_osmsource"},
"type": "OpenLayers.Layer.OSM",
"name": "mapnik",
"visibility": True,
"fixed": True,
"group": "background"
}]
if 'geonode.geoserver' in INSTALLED_APPS:
LOCAL_GEOSERVER = {
"source": {
"ptype": "gxp_wmscsource",
"url": OGC_SERVER['default']['PUBLIC_LOCATION'] + "wms",
"restUrl": "/gs/rest"
}
}
baselayers = MAP_BASELAYERS
MAP_BASELAYERS = [LOCAL_GEOSERVER]
MAP_BASELAYERS.extend(baselayers)
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d '
'%(thread)d %(message)s'
},
'simple': {
'format': '%(message)s',
},
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler',
}
},
"loggers": {
"django": {
"handlers": ["console"], "level": "ERROR", },
"geonode": {
"handlers": ["console"], "level": "INFO", },
"geonode.qgis_server": {
"handlers": ["console"], "level": "ERROR", },
"gsconfig.catalog": {
"handlers": ["console"], "level": "ERROR", },
"owslib": {
"handlers": ["console"], "level": "ERROR", },
"pycsw": {
"handlers": ["console"], "level": "INFO", },
"celery": {
'handlers': ["console"], 'level': 'ERROR', },
},
}
# Additional settings
X_FRAME_OPTIONS = 'ALLOW-FROM %s' % SITEURL
CORS_ORIGIN_ALLOW_ALL = True
GEOIP_PATH = "/usr/local/share/GeoIP"
ACCOUNT_OPEN_SIGNUP = True
ACCOUNT_APPROVAL_REQUIRED = True