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.

Enable sensitive areas

In order to enable sensitivity module, in the custom settings file, add the following code:

# Enable sensitivity module
INSTALLED_APPS =+ ('geotrek.sensitivity', )

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

Using IGN Geoportail WMTS tiles

Specify the tiles URLs this way in your custom Django setting file:

LEAFLET_CONFIG['TILES'] = [
    ('Scan', 'http://{s}.tile.osm.org/{z}/{x}/{y}.png', '(c) OpenStreetMap Contributors'),
    ('Ortho', 'http://{s}.tiles.mapbox.com/v3/openstreetmap.map-4wvf9l0l/{z}/{x}/{y}.jpg', '(c) MapBox'),
]

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: string
  • description: string
  • website: string
  • phone: string
  • pictures: list of objects with url and copyright attributes
  • category: object with id and label 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

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

Share services between several Geotrek instances

As explained in the design section, Geotrek relies on several services. They are generic and reusable, and can thus be shared between several instances, in order to save system resources for example.

A simple way to achieve this is to install one instance with everything as usual (standalone), and plug the other instances on its underlying services.

Database

Sharing your postgreSQL server is highly recommended. Create several databases for each of your instances.

Then in etc/settings.ini, adjust the host and dbname sections of each instance.

Capture and conversion

On the standalone server, make sure the services will be available to others. Add the following lines in its settings.ini :

[convertit]
host = 0.0.0.0

[screamshotter]
host = 0.0.0.0

In custom.py, point the tiles URL to the shared services (replace SERVER by the one you installed as standalone) :

MAPENTITY_CONFIG['CONVERSION_SERVER'] = 'http://SERVER:6543'
MAPENTITY_CONFIG['CAPTURE_SERVER'] = 'http://SERVER:8001'

Shutdown useless services

Now that your instances point the shared server. You can shutdown the useless services on each instance.

Start by stopping everything :

sudo stop geotrek

Before you used to run make env_standalone deploy on every server. Now you will have only one standalone, and on the other ones the Geotrek application only.

To achieve this, you will just have to run the prod environment instead of standalone in the deployment procedure (or when settings are changed) :

make env_prod deploy

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.