Renseigner les fichiers de configuration

Modifier le fichier de configuration

Côté backend

Les fichiers de configuration sont dans le dossier config. Le fichier à modifier est config.toml. Il peut-être créé en copiant le fichier config.toml.template vers config.toml:

$ cp config.toml.template config.toml

Editez alors les différents paramètres de ce fichier.

Fichier config.toml :

# Database
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://geonatuser:monpassachanger@127.0.0.1:5432/geonaturedb"
SQLALCHEMY_TRACK_MODIFICATIONS = false

# JWT Auth
JWT_SECRET_KEY = 'jwt-secret-string'
JWT_BLACKLIST_ENABLED = true
JWT_BLACKLIST_TOKEN_CHECKS = ['access', 'refresh']

# Application
appName = 'GeoNature-citizen'                               # Application name in the home page
DEFAULT_LANGUAGE = 'fr'
FLASK_ADMIN_FLUID_LAYOUT = true

# Debug
DEBUG = false
SQLALCHEMY_DEBUG_LEVEL = 'WARNING'

URL_APPLICATION = "http://mydomain.org"         # Replace mydomain.org by your domain
API_TAXHUB = "http://mytaxhub.org/api/"         # Replace mytaxhub.org by your TaxHub url
# URL to get info about a municipality (from a latitude and a longitude)
API_CITY = "https://nominatim.openstreetmap.org/reverse"

SECRET_KEY = 'MyS3cr3tK3y'
CONFIRM_MAIL_SALT = 'your-secret-salt' # secret salt for corfirm mail token

MEDIA_FOLDER = 'media'

#HCAPTCHA_SECRET_KEY=


# Rewards
REWARDS_ENABLED = false


# Verify observations
VERIFY_OBSERVATIONS_ENABLED = false



[RESET_PASSWD]
    SUBJECT = "Réinitialisation de votre mot de passe"
    FROM = 'contact@geonature-citizen.fr'
    HTML_TEMPLATE = """<p>Bonjour,</p>
        <p>Vous recevez cet email car vous avez demandé la réinitialisation du mot de passe de votre compte sur {app_url}.</p>
        <p>Votre nouveau mot de passe : <code>{passwd}</code></p>
        <p>Votre nom d'utilisateur, au cas où vous l'auriez oublié, est le suivant : <code>{username}</code></p>
        <p>Merci d'avoir utilisé notre site !<p>
        <p>L'équipe <a href="{app_url}">{app_name}</a></p>
        """

[CONFIRM_EMAIL]
    USE_CONFIRM_EMAIL = true
    SUBJECT = "Activez votre compte"
    FROM = 'contact@geonature-citizen.fr'
    HTML_TEMPLATE = """<p> Bonjour,</p>
        <p>Nous vous confirmons que votre compte a bien été créé.</p>
        <p> Afin d'activer votre compte veuillez <a href="{activate_url}">cliquer ici.</a>
        <p>Nous vous souhaitons la bienvenue sur notre site.</p><br />
        <p>Bien à vous.</p>
        <p>L'équipe <a href="{app_url}">{app_name}</a></p>
    """
    NO_VALIDATION_HTML_TEMPLATE = """<p> Bonjour,</p>
        <p>Nous vous confirmons que votre compte a bien été créé.</p>
        <p>Nous vous souhaitons la bienvenue sur notre site.</p><br />
        <p>Bien à vous.</p>
        <p>L'équipe <a href="{app_url}">{app_name}</a></p>
    """

[VALIDATION_EMAIL]
    SUBJECT = "Mise à jour de votre observation {observation}"
    HTML_TEMPLATE = """
        <p>Bonjour,</p>
        <p>{message}</p>
        <p>Pour retrouver votre observation, <a href="{obs_link}">cliquez ici.</a></p>
    """
    

[MAIL]
    MAIL_USE_SSL = false
    MAIL_STARTTLS = true
    MAIL_HOST = 'smtpd host'
    MAIL_PORT = 493   # mandatory SSL port
    MAIL_AUTH_LOGIN = 'smtpd/relay host username'
    MAIL_AUTH_PASSWD = 'smtpd/relay host password'
    MAIL_FROM_ADDR = 'fcloitre@dbwildlife.info'


# API flasgger main config

# Flaskadmin map default center
DEFAULT_CENTER_LAT = 45
DEFAULT_CENTER_LONG = 5

Pour que les modifications de ce fichier soient prises en compte, vous devez éxécuter la commande sudo supervisorctl restart gncitizen_api.

Côté frontend

Les fichiers de configuration du frontend se trouvent dans le dossier ./frontend/src/conf.

Les fichiers app.config.ts et map.config.ts permettent de personnaliser la configuration définie par défaut dans main.config.ts. Il sont créés lors de l’installation ou en copiant les fichiers app.config.ts.sample vers app.config.ts et map.config.ts.sample vers map.config.ts :

$ cd ./frontend/src/conf
$ cp app.config.ts.template app.config.ts
$ cp map.config.ts.template map.config.ts

Editez alors les différents paramètres de ces fichiers.

Fichier app.config.ts :

export const AppConfig = {
    appName: 'GeoNature-citizen',
    API_ENDPOINT: 'http://localhost:5002/api',
    API_TAXHUB: 'http://localhost:5000/api',
    API_CITY: 'https://nominatim.openstreetmap.org/reverse',
    // HCAPTCHA_SITE_KEY: null,
    // FRONTEND: {
    //     PROD_MOD: true,
    //     MULTILINGUAL: false,
    //     DISPLAY_FOOTER: true,
    //     DISPLAY_TOPBAR: true,
    //     DISPLAY_SIDEBAR: true,
    //     DISPLAY_STATS: true,
    //     DISPLAY_BADGES: true,
    //     NEW_OBS_FORM_MODAL_VERSION: true,
    // },
    // META: {
    //     keywords: 'biodiversite enquetes participatif observations',
    // },
    // about: true,
    URL_APPLICATION: 'http://127.0.0.1:4200',
    // REWARDS: true,
    // termsOfUse: {
    //     fr: 'assets/cgu.pdf',
    //     en: 'assets/termsOfUse.pdf',
    // },
    // signup: 'optional', // never|optional|always
    // email_contact: false,
    // platform_intro: {
    //     fr: 'Bienvenue<br /> sur GeoNature Citizen',
    //     en: 'Welcome<br /> on GeoNature Citizen',
    // },
    // platform_teaser: {
    //     fr: 'Hae duae provinciae bello quondam piratico catervis mixtae praedonum a Servilio pro consule missae sub iugum factae sunt vectigales. et hae quidem regiones velut in prominenti terrarum lingua positae ob orbe eoo monte Amano disparantur.',
    //     en: 'Hae duae provinciae bello quondam piratico catervis mixtae praedonum a Servilio pro consule missae sub iugum factae sunt vectigales. et hae quidem regiones velut in prominenti terrarum lingua positae ob orbe eoo monte Amano disparantur.',
    // },
    // platform_participate: {
    //     fr: 'PARTICIPER AU PROGRAMME',
    //     en: 'PARTICIPATE',
    // },
    // programs_label: {
    //     fr: 'Programmes',
    //     en: 'Surveys',
    // },
    // program_label: {
    //     fr: 'Le programme',
    //     en: 'Survey',
    // },
    // program_share_an_observation: {
    //     fr: 'PARTAGER UNE OBSERVATION',
    //     en: 'SHARE AN OBSERVATION',
    // },
    // program_add_an_observation: {
    //     fr: 'AJOUTER UNE OBSERVATION',
    //     en: 'CONTRIBUTE AN OBSERVATION',
    // },
    // program_allow_email_contact: {
    //     fr: "J'accepte que mon adresse e-mail puisse être utilisée pour recontacter à propos de mon observation",
    //     en: 'I agree that my e-mail address can be used to recontact about my observation',
    // },
    // taxonDisplayImageWhenUnique: true,
    // taxonSelectInputThreshold: 7,
    // taxonAutocompleteInputThreshold: 12,
    // taxonAutocompleteFields: [
    //     'nom_complet',
    //     'nom_vern',
    //     'nom_vern_eng',
    //     'cd_nom',
    // ],
    // taxonDisplaySciName: true,
    // program_list_observers_names: true,
    // program_list_sort: '-timestamp_create',
    // details_espece_url: '<url_inpn_or_atlas>/cd_nom/', // !! gardez bien le cd_nom/ dans l'url
    // registration_message: 'Vous inscrire vous permet de gérer vos observations',
    // imageUpload: {
    //     maxHeight: 1440,
    //     maxWidth: 1440,
    //     quality: 0.9,
    // },
};

Fichier map.config.ts :

export const MAP_CONFIG = {
    // DEFAULT_PROVIDER: 'OpenStreetMapOrg',
    // BASEMAPS: [
    //     {
    //         name: 'OpenStreetMapOrg',
    //         maxZoom: 19,
    //         layer: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
    //         subdomains: 'abc',
    //         attribution:
    //             '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Tiles style by <a href="https://www.hotosm.org/" target="_blank">Humanitarian OpenStreetMap Team</a> hosted by <a href="https://openstreetmap.fr/" target="_blank">OpenStreetMap France</a>',
    //     },
    // {
    //   name: "OpenStreetMapFRHot",
    //   maxZoom: 19,
    //   layer: "//{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",
    //   subdomains: "abc",
    //   attribution:
    //     '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Tiles style by <a href="https://www.hotosm.org/" target="_blank">Humanitarian OpenStreetMap Team</a> hosted by <a href="https://openstreetmap.fr/" target="_blank">OpenStreetMap France</a>'
    // },
    // {
    //   name: "OpenStreetMapCH",
    //   maxZoom: 18,
    //   layer: "//tile.osm.ch/switzerland/{z}/{x}/{y}.png",
    //   subdomains: "abc",
    //   attribution:
    //     '&copy; <a href="&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
    //   bounds: [[45, 5], [48, 11]]
    // },
    // {
    //   name: "OpenStreetMapDE",
    //   maxZoom: 18,
    //   layer: "//{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png",
    //   subdomains: "abc",
    //   attribution:
    //     '&copy; <a href="&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    // },
    // {
    //   name: "OpenStreetMapBZH",
    //   maxZoom: 18,
    //   layer: "//tile.openstreetmap.bzh/br/{z}/{x}/{y}.png",
    //   subdomains: "",
    //   attribution:
    //     '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Tiles courtesy of <a href="http://www.openstreetmap.bzh/" target="_blank">Breton OpenStreetMap Team</a>',
    //   bounds: [[46.2, -5.5], [50, 0.7]]
    // },
    // {
    //     name: 'OpenTopoMap',
    //     maxZoom: 17,
    //     layer: '//{s}.opentopomap.org/{z}/{x}/{y}.png',
    //     subdomains: 'abc',
    //     attribution: '© OpenTopoMap',
    // },
    // {
    //     name: 'IGN Vue satellite',
    //     maxZoom: 19,
    //     layer: 'https://wxs.ign.fr/decouverte/geoportail/wmts?&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&TILEMATRIXSET=PM&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&STYLE=normal&FORMAT=image/jpeg&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}',
    //     subdomains: 'abc',
    //     attribution: '© IGN-F/Geoportail',
    // },
    // {
    //     name: 'IGN Cartes',
    //     maxZoom: 19,
    //     layer: 'https://wxs.ign.fr/decouverte/geoportail/wmts?&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&TILEMATRIXSET=PM&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&STYLE=normal&FORMAT=image/png&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}',
    //     subdomains: 'abc',
    //     attribution: '© IGN-F/Geoportail',
    // },
    // {
    //   // ⚠ google's terms&conditions
    //   // https://github.com/Leaflet/Leaflet/blob/master/FAQ.md#i-want-to-use-google-maps-api-tiles-with-leaflet-can-i-do-that
    //   name: "GoogleSatellite",
    //   maxZoom: 20,
    //   layer: "//mt{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}",
    //   subdomains: "1",
    //   attribution: "© GoogleMap"
    // }
    // ],
    // CENTER: [46.52863469527167, 2.43896484375],
    // ZOOM_LEVEL: 6,
    // ZOOM_LEVEL_RELEVE: 15,
    // NEW_OBS_POINTER: 'assets/pointer-blue2.png',
    // OBS_POINTER: 'assets/pointer-green.png',
    // LOCATE_CONTROL_TITLE: {
    //     fr: 'Me localiser',
    //     en: 'Show me where i am',
    // },
};

Configuration de l’authentification

Le fichier frontend/src/conf/app.config.ts permet notamment de configuer l’authentification.

Il y a 3 possibilités :

  • un mode sans authentifiaction (signup : "never"),

  • un mode avec authentification optionnelle (signup : "optional") tout en conservant le mode sans authentification,

  • un mode avec authentification obligatoire (signup : "always").