ADVANCED CONFIGURATION¶
Custom setting file¶
Geotrek configuration is currently restricted to values present in etc/settings.ini
.
However, it is still possible to write a custom Django setting file.
- Create your a file in geotrek/settings/custom.py with the following content :
from .prod import *
# My custom value
HIDDEN_OPTION = 3.14
- Add this
etc/settings.ini
to specify the newly created setting :
[django]
settings = settings.custom
- As for any change in settings, re-run
make env_standalone deploy
.
Disable modules and components¶
In order to disable a full set of features, in the custom settings file, add the following code:
# Disable infrastructure and maintenance
_INSTALLED_APPS = list(INSTALLED_APPS)
_INSTALLED_APPS.remove('geotrek.infrastructure')
_INSTALLED_APPS.remove('geotrek.maintenance')
INSTALLED_APPS = _INSTALLED_APPS
In order to remove notion of trails:
TRAIL_MODEL_ENABLED = False
In order to remove zoning combo-boxes on list map:
LAND_BBOX_CITIES_ENABLED = True
LAND_BBOX_DISTRICTS_ENABLED = True
LAND_BBOX_AREAS_ENABLED = False
notes: | By doing so, some software upgrades may not be as smooth as usual. Never forget to mention this customization if you ask for community support. |
---|
Sensitive areas¶
In order to enable sensitivity module, in the custom settings file, add the following code:
# Enable sensitivity module
INSTALLED_APPS += ('geotrek.sensitivity', )
The following settings are related to sensitive areas:
# Default radius of sensitivity bubbles when not specified for species
SENSITIVITY_DEFAULT_RADIUS = 100 # meters
# Buffer around treks to intersects sensitive areas
SENSITIVE_AREA_INTERSECTION_MARGIN = 500 # meters
WYSIWYG editor configuration¶
Text form fields are enhanced using TinyMCE.
Its configuration can be customized using advanced settings (see above paragraph).
For example, in order to control which buttons are to be shown, and which tags are to be kept when cleaning-up, add this bloc :
TINYMCE_DEFAULT_CONFIG = {
'theme_advanced_buttons1': 'bold,italic,forecolor,separator,code',
'valid_elements': "img,p,a,em/i,strong/b",
}
This will apply to all text fields.
For more information on configuration entries available, please refer to the official documentation of TinyMCE version 3.
View attachments in the browser¶
Attached files are downloaded by default by browser, with the following line, files will be opened in the browser :
MAPENTITY_CONFIG['SERVE_MEDIA_AS_ATTACHMENT'] = False
Change or add WMTS tiles layers (IGN, OSM, Mapbox…)¶
By default, you have 2 basemaps layers in your Geotrek-admin (OSM and OSM black and white).
You can change or add more basemaps layers.
Specify the tiles URLs this way in your custom Django setting file:
LEAFLET_CONFIG['TILES'] = [
('OSM', 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', '(c) OpenStreetMap Contributors'),
('OpenTopoMap', 'http://a.tile.opentopomap.org/{z}/{x}/{y}.png', 'Map data: © OpenStreetMap contributors, SRTM | Map style: © OpenTopoMap (CC-BY-SA)'),
]
Example with IGN and OSM basemaps :
LEAFLET_CONFIG['TILES'] = [
('IGN Scan', 'http://gpp3-wxs.ign.fr/YOURAPIKEY/geoportail/wmts?LAYER=GEOGRAPHICALGRIDSYSTEMS.MAPS&EXCEPTIONS=text/xml&FORMAT=image/jpeg&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}','(c) IGN Geoportail'),
('IGN Scan Express', 'http://gpp3-wxs.ign.fr/YOURAPIKEY/geoportail/wmts?LAYER=GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD&EXCEPTIONS=text/xml&FORMAT=image/jpeg&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}','(c) IGN Geoportail'),
('IGN Ortho', 'http://gpp3-wxs.ign.fr/YOURAPIKEY/geoportail/wmts?LAYER=ORTHOIMAGERY.ORTHOPHOTOS&EXCEPTIONS=text/xml&FORMAT=image/jpeg&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}','(c) IGN Geoportail'),
('IGN Cadastre', 'http://gpp3-wxs.ign.fr/YOURAPIKEY/geoportail/wmts?LAYER=CADASTRALPARCELS.PARCELS&EXCEPTIONS=text/xml&FORMAT=image/png&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=bdparcellaire_o&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}','(c) IGN Geoportail'),
('OSM', 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png','(c) OpenStreetMap contributors'),
('OSM Mapbox Outdoors', 'https://api.mapbox.com/v4/mapbox.outdoors/{z}/{x}/{y}.png?access_token=pk.YOURAPIKEY','(c) OpenStreetMap contributors / Mapbox'),
('OSM Stamen Terrain', 'http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg','(c) OpenStreetMap contributors / Stamen Design'),
('OpenTopoMap', 'http://a.tile.opentopomap.org/{z}/{x}/{y}.png', 'Map data: © OpenStreetMap contributors, SRTM | Map style: © OpenTopoMap (CC-BY-SA)'),
]
To use IGN Geoportail WMTS tiles API, you need an API key with subscribing on http://professionnels.ign.fr/visualisation. Choose WebMercator WMTS tiles.
External authent¶
You can authenticate user against a remote database table or view.
To enable this feature, fill authent_dbname and other fields in etc/settings.ini
.
Expected columns in table/view are :
- username : string (unique)
- first_name : string
- last_name : string
- password : string (simple md5 encoded, or full hashed and salted password)
- email : string
- level : integer (1: readonly, 2: redactor, 3: path manager, 4: trekking manager, 6: administrator)
- structure : string
- lang : string (language code)
notes: | User management will be disabled from Administration backoffice. In order to disable remote login, just remove authent_dbname value in settings file, and update instance (see paragraph above). Geotrek can support many types of users authentication (LDAP, oauth, …), contact-us for more details. |
---|
Map layers colors and style¶
All layers colors can be customized from the settings. See Leaflet reference for vectorial layer style.
- To apply these style changes, re-run
sudo supervisorctl restart all
.
MAP_STYLES['path'] = {'color': 'red', 'weight': 5}
Or change just one parameter (the opacity for example) :
MAP_STYLES['city']['opacity'] = 0.8
Regarding colors that depend from database content, such as land layers (physical types, work management…) or restricted areas. We use a specific setting that receives a list of colors :
COLORS_POOL['restrictedarea'] = ['#ff00ff', 'red', '#ddddd'...]
See the default values in geotrek/settings/base.py
for the complete list
of available styles.
Restart the application for changes to take effect.
External raster layers¶
It is possible to add overlay tiles layer on maps. For example, it can be useful to:
- Get the cadastral parcels on top of satellite images
- Home made layers (with Tilemill or QGisMapserver for example). Like the park center borders, traffic maps, IGN BDTopo® or even the Geotrek paths that are marked as invisible in the database!
In custom.py
, just add the following lines:
LEAFLET_CONFIG['OVERLAYS'] = [
('Coeur de parc', 'http://serveur/coeur-parc/{z}/{x}/{y}.png', '© PNF'),
]
Expected properties¶
For GeoJSON
files, you can provide the following properties :
title
: stringdescription
: stringwebsite
: stringphone
: stringpictures
: list of objects withurl
andcopyright
attributescategory
: object withid
andlabel
attributes
Disable darker map backgrounds¶
Since IGN map backgrounds are very dense and colourful, a dark opacity is applied. In order to disable, change this MapEntity setting :
MAPENTITY_CONFIG['MAP_BACKGROUND_FOGGED'] = False
Override public document OpenOffice template¶
WARNING: Documentation to be updated. Geotrek-admin now uses Weasyprint to create public PDF based on HTML templates
and no more on ODT templates. Default HTML templates are in geotrek/trekking/templates/
and can be copied in var/media/templates/
with same path and file names to be overriden.
Copy the file geotrek/trekking/templates/trekking/trek_public.odt
to
var/media/templates/trekking/trek_public.odt
.
Edit the copy using OpenOffice.
Note
The default template may change in the future versions. You will be in charge of porting the modification to your copy.
Custom font in public document OpenOffice template¶
In order to use custom fonts in trek PDF, it is necessary to install the font files on the server.
Microsoft fonts like Arial and Verdana can be installed via the package manager
sudo apt-get install ttf-mscorefonts-installer
For specific fonts, copy the .ttf
(or .otf
) files into the folder
/usr/local/share/fonts/custom/
as root, and run the following command
fc-cache
For more information, check out Ubuntu documentation.
Custom colors in public document OpenOffice template¶
Trek export geometries are translucid red by default. In order to control the apparence of objects in public trek exports, use the following setting :
MAP_STYLES['print']['path'] = {'weight': 3}
See Leaflet reference documentation for detail about layers apparence.
Custom logos¶
You might also need to deploy logo images in the following places :
var/media/upload/favicon.png
var/media/upload/logo-login.png
var/media/upload/logo-header.png
Control number of workers and request timeouts¶
By default, the application runs on 4 processes, and timeouts after 30 seconds.
To control those values, add a section in etc/settings.ini
for each running service.
See conf/settings-defaults.cfg
for an exhaustive list:
[gunicorn-app-conf]
workers = 4
timeout = 30
To know how many workers you should set, please refer to gunicorn documentation.