From 2e551daa9db99cc77dbf5cd3cdbb03a1d9305b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 18 Jun 2022 10:31:54 +0200 Subject: [PATCH] add gnm_update_settings command to set toodego specific settings (#64909) --- .../management/commands/gnm_reporting.py | 2 + .../commands/gnm_update_settings.py | 731 ++++++++++++++++++ debian/50gnm.py | 650 ---------------- debian/python3-combo-plugin-gnm.cron.hourly | 3 + 4 files changed, 736 insertions(+), 650 deletions(-) create mode 100644 combo_plugin_gnm/management/commands/gnm_update_settings.py create mode 100755 debian/python3-combo-plugin-gnm.cron.hourly diff --git a/combo_plugin_gnm/management/commands/gnm_reporting.py b/combo_plugin_gnm/management/commands/gnm_reporting.py index 864c35b..18bbf4c 100644 --- a/combo_plugin_gnm/management/commands/gnm_reporting.py +++ b/combo_plugin_gnm/management/commands/gnm_reporting.py @@ -32,6 +32,8 @@ from combo.utils import requests class Command(BaseCommand): def handle(self, *args, **options): + if not getattr(settings, 'GNM_REPORTING', False): + return reporting_user_email = settings.TEMPLATE_VARS.get('reporting_user_email') reporting_user = None if reporting_user_email: diff --git a/combo_plugin_gnm/management/commands/gnm_update_settings.py b/combo_plugin_gnm/management/commands/gnm_update_settings.py new file mode 100644 index 0000000..a0cc629 --- /dev/null +++ b/combo_plugin_gnm/management/commands/gnm_update_settings.py @@ -0,0 +1,731 @@ +# combo-plugin-gnm - Combo GNM plugin +# Copyright (C) 2022 Entr'ouvert +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import json +import os + +from django.core.management.base import BaseCommand +from django.conf import settings +from django.db import connection + + +class Command(BaseCommand): + def handle(self, *args, **options): + # update settings.json of GNM tenants + + self.extra_settings_filepath = os.path.join(connection.tenant.get_directory(), 'gnm-settings.json') + if not os.path.exists(self.extra_settings_filepath): + return + + settings_filepath = os.path.join(connection.tenant.get_directory(), 'settings.json') + if os.path.exists(settings_filepath): + with open(settings_filepath) as fd: + self.settings_json = json.load(fd) + else: + self.settings_json = {} + + self.update_settings_dict() + self.import_extra_settings() + self.set_no_logs() + + self.settings_json['JSON_CELL_TYPES.update'] = self.settings_json['JSON_CELL_TYPES'] + del self.settings_json['JSON_CELL_TYPES'] + self.settings_json['COMBO_ASSET_SLOTS.update'] = self.settings_json['COMBO_ASSET_SLOTS'] + del self.settings_json['COMBO_ASSET_SLOTS'] + del self.settings_json['self'] + + with open(settings_filepath + '.new', 'w') as fd: + json.dump(self.settings_json, fd, indent=2, ensure_ascii=False, sort_keys=True) + os.replace(settings_filepath + '.new', settings_filepath) + + def update_settings_dict(self): + MELLON_ADD_AUTHNREQUEST_NEXT_URL_EXTENSION = True + + GNM_REPORTING = True + + COMBO_MAP_TILE_URLTEMPLATE = "https://tiles.entrouvert.org/hdm/{z}/{x}/{y}.png" + COMBO_MAP_ATTRIBUTION = "© OpenStreetMap" + COMBO_GEOCODING_SERVICE = 'https://nominatim.entrouvert.org' + + JSON_CELL_TYPES = self.settings_json.get('JSON_CELL_TYPES.update') or {} + JSON_CELL_TYPES = { + "velov": { + "url": "https://%(data_username)s:%(data_password)s@download.data.grandlyon.com/ws/rdata/jcd_jcdecaux.jcdvelov/all.json?field=gid&value=[gid]" + % settings.DATA_CREDENTIALS, + "name": "Velov", + "cache_duration": 60, + "force_async": False, + "auto_refresh": 90, + "form": [{"varname": "gid", "type": "string", "label": "GID de la station"}], + }, + "taxi": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/taxi/?property:gid={{gid}}", + "name": "Station de taxi", + "cache_duration": 86400, + "force_async": False, + "form": [{"varname": "gid", "type": "string", "label": "GID de la station"}], + }, + "mdr": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/mdr/?property:identifiant={{identifiant}}", + "cache_duration": 86400, + "force_async": False, + "name": "Maison de la Métropole de Lyon", + "toodego:page": True, + "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], + }, + "piscine": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/piscine/?property:identifiant={{identifiant}}", + "cache_duration": 86400, + "force_async": False, + "name": "Piscine de la Métropole de Lyon", + "toodego:page": True, + "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], + }, + "mairie": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/mairie/?property:identifiant={{identifiant}}", + "cache_duration": 86400, + "force_async": False, + "name": "Mairie", + "toodego:page": True, + "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], + }, + "decheterie": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/decheterie/?property:identifiant={{identifiant}}", + "cache_duration": 86400, + "force_async": False, + "name": "Déchèterie", + "toodego:page": True, + "toodego:page-title-template": "Déchèterie {{properties.nom}}", + "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], + }, + "donnerie": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/donnerie/?property:identifiant={{identifiant}}", + "cache_duration": 86400, + "force_async": False, + "name": "Donnerie", + "toodego:page": True, + "toodego:page-title-template": "Donnerie {{properties.nom}}", + "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], + }, + "bibliotheque": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/bibliotheque/?property:identifiant={{identifiant}}", + "cache_duration": 86400, + "force_async": False, + "name": "Bibliothèque", + "toodego:page": True, + "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], + }, + "aire-de-covoiturage": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/aire-de-covoiturage/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Aire de covoiturage", + "form": [{"varname": "gid", "type": "string", "label": "Identifiant"}], + }, + "airquality": { + "url": "{% if q_lat or lat %}http://api.atmo-aura.fr/partenaires/indice_request?api_token=6df2b0b505cc73c5545467758827458e&longitude={% firstof q_lon lon %}&latitude={% firstof q_lat lat %}{% endif %}", + "cache_duration": 300, + "force_async": False, + "name": "Qualité de l'air", + "form": [ + { + "varname": "lat", + "type": "string", + "label": "Latitude", + "required": False, + }, + { + "varname": "lon", + "type": "string", + "label": "Longitude", + "required": False, + }, + ], + "additional-data": [ + { + "key": "air2go", + "url": "{% if q_lat or lat %}http://api.atmo-aura.fr/partenaires/indice_request?api_token=6df2b0b505cc73c5545467758827458e&longitude={% firstof q_lon lon %}&latitude={% firstof q_lat lat %}{% endif %}", + }, + { + "key": "nominatim", + "url": "{% if q_lat or lat %}{{passerelle_url}}base-adresse/nominatim/reverse?lat={% firstof q_lat lat %}&lon={% firstof q_lon lon %}&format=json{% endif %}", + "cache_duration": 3600, + }, + { + "key": "places", + "url": "{% if user_nameid %}{{ passerelle_url }}jsondatastore/lieux-favoris/data/?name_id={{user_nameid}}{% endif %}", + }, + { + "key": "place_geoloc", + "url": "{% if places %}{{ passerelle_url }}base-adresse/nominatim/search?q={{ places.data.0.text }}&format=json{% endif %}", + "cache_duration": 3600, + }, + { + "key": "place2_geoloc", + "url": "{% if places|length > 1 %}{{ passerelle_url }}base-adresse/nominatim/search?q={{ places.data.1.text }}&format=json{% endif %}", + "cache_duration": 3600, + }, + ], + "actions": { + "geocode": { + "url": "{{ passerelle_url }}base-adresse/nominatim/search?q={{ q }}&format=json", + "method": "get", + "response": "raw", + } + }, + }, + "pollen": { + "url": "https://download.data.grandlyon.com/ws/rdata/rnsa_reseau_aerobio.rnsabulletin/all.json", + "cache_duration": 300, + "force_async": False, + "name": "Info Pollen", + "additional-data": [ + { + "key": "syntheses", + "url": "https://download.data.grandlyon.com/ws/rdata/rnsa_reseau_aerobio.rnsabulletin/all.json?field=type&value=Synthese", + } + ], + }, + "places": { + "url": "{{passerelle_url}}jsondatastore/lieux-favoris/data/?name_id={{user_nameid}}", + "name": "Lieux favoris", + "force_async": False, + "cache_duration": 600, + "additional-data": [{"key": "userdata", "url": "{{idp_url}}api/users/{{user_nameid}}"}], + "actions": { + "create": { + "url": "{{passerelle_url}}jsondatastore/lieux-favoris/data/create?name_id={{user_nameid}}" + }, + "update": { + "url": "{{passerelle_url}}jsondatastore/lieux-favoris/data/{{id}}/?name_id={{user_nameid}}" + }, + "delete": { + "url": "{{passerelle_url}}jsondatastore/lieux-favoris/data/{{id}}/delete?name_id={{user_nameid}}" + }, + }, + }, + "silo-a-verre": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/silo-a-verre/?property:identifiant={{identifiant}}", + "cache_duration": 86400, + "force_async": False, + "name": "Silo à verre", + "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], + }, + "tcl": { + "url": "{{passerelle_url}}tcl/tcl/stop/{{id}}", + "auto_refresh": 25, + "cache_duration": 10, + "force_async": False, + "name": "Arrêt TCL", + "form": [{"varname": "id", "type": "string", "label": "Identifiant"}], + }, + "goto": { + "url": "{% load l10n %}{% localize off %}{% if lat1 %}{{cityway_api_url}}api/journeyplanner/opt/PlanTrips/json?DepartureType=COORDINATES&DepartureLatitude={{lat1}}&DepartureLongitude={{lng1}}&ArrivalType=COORDINATES&ArrivalLatitude={{lat2}}&ArrivalLongitude={{lng2}}&Date={{date}}&DateType=DEPARTURE&TripModes={{tripmode}}&Algorithm=FASTEST&BikeSecurityLevel=None&BikeSpeed=12&WalkSpeed=4&MaxCarDistance=100&MaxBikeDistance=100&MaxWalkDistance=3000&AvoidDisruptions=1&StopToPlaceCar=1&SpecificOptions=GetOn;3|GetOff;4|TinyDistance;300|VLS;0|CARSHARING;0&UserId={% firstof cityway_api_userid 'toodego' %}&user_key={{cityway_api_userkey}}{% endif %}{% endlocalize %}", + "cache_duration": 60, + "force_async": False, + "name": "M'y rendre", + "loading-message": u'Calcul…', + "varnames": ["lat1", "lng1", "lat2", "lng2", "date", "to"], + "form": [ + { + "varname": "tripmode", + "type": "string", + "label": "Mode de transport (WALK, BIKE, PT, CAR)", + } + ], + }, + "cut-profile": { + "url": "{{idp_url}}api/users/{{user_nameid}}/", + "name": "Profil CUT", + "auto_refresh": 60, + }, + "profile-info": {"url": "{{idp_url}}api/users/{{user_nameid}}/", "name": "Infos de profil"}, + "suggestions": { + "name": "Suggestions", + "url": "{{idp_url}}api/users/{{user_nameid}}", + "force_async": True, + "loading-message": "Assemblage en cours, quelques secondes…", + "additional-data": [ + { + "key": "places", + "url": "{{passerelle_url}}jsondatastore/lieux-favoris/data/?name_id={{user_nameid}}", + } + ], + }, + "alerte-qualite-de-l-air": { + "url": "{{passerelle_url}}feeds/alertes-qualite-de-lair/json", + "cache_duration": 600, + "force_async": True, + "name": "Alerte qualité de l'air", + }, + "mairie-usager": { + "name": "Mairie de l'usager", + "url": "{{idp_url}}api/users/{{user_nameid}}/", + "form": [{"varname": "text", "type": "text", "label": "Texte"}], + }, + "group-title": { + "name": "Intertitre", + "url": "{{}}", + "form": [{"varname": "text", "type": "text", "label": "Texte"}], + }, + "stats": { + "name": "Statistiques tuiles", + "url": "{{portal_url}}api/dashboard/tile-stats/", + }, + "parkingtr": { + "url": "https://%(data_username)s:%(data_password)s@download.data.grandlyon.com/wfs/rdata?SERVICE=WFS&VERSION=2.0.0&outputformat=GEOJSON&request=GetFeature&typename=pvo_patrimoine_voirie.pvoparkingtr&filter=pkgid[pkgid]" + % settings.DATA_CREDENTIALS, + "cache_duration": 86400, + "force_async": False, + "name": "Parking", + "form": [{"varname": "pkgid", "type": "string", "label": "Identifiant"}], + }, + "parc-velo": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/parc-velo/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Parc de stationnement vélos", + "form": [{"varname": "gid", "type": "string", "label": "Identifiant"}], + }, + "autopartage": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/autopartage/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Autopartage", + "form": [{"varname": "gid", "type": "string", "label": "Identifiant"}], + }, + "stationnement-pmr": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/stationnement-pmr/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Stationnement réglementé pour les PMR", + "form": [{"varname": "gid", "type": "string", "label": "Identifiant"}], + }, + "toilette": { + "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/toilette/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Toilette publique", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "evenement-routier": { + "url": "https://%(data_username)s:%(data_password)s@download.data.grandlyon.com/wfs/rdata?SERVICE=WFS&VERSION=2.0.0&outputformat=GEOJSON&request=GetFeature&typename=pvo_patrimoine_voirie.pvoevenement&filter=id[id]" + % settings.DATA_CREDENTIALS, + "cache_duration": 86400, + "force_async": False, + "name": "Evenement routier", + "form": [{"varname": "id", "type": "string", "label": "Identifiant"}], + }, + "cartads-dossiers": { + "url": "{{passerelle_url}}grandlyon-cartads-cs/{{slug}}/files?name_id={{user_nameid}}", + "cache_duration": 0, + "force_async": True, + "name": "Dossiers Cart@DS", + "form": [{"varname": "slug", "type": "string", "label": "Slug du connecteur"}], + "actions": { + "unsubscribe": { + "url": "{{passerelle_url}}grandlyon-cartads-cs/{{slug}}/unsubscribe?name_id={{user_nameid}}", + }, + }, + }, + "urgence-sanitaire-soins": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/urgence-sanitaire-soins/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Urgence sanitaire Covid 19 - Accès aux soins", + "toodego:page": True, + "template-name": "combo/json/urgence-sanitaire.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "urgence-sanitaire-alimentation": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/urgence-sanitaire-alimentation/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Urgence sanitaire Covid 19 - Alimentation", + "toodego:page": True, + "template-name": "combo/json/urgence-sanitaire.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "urgence-sanitaire-hebergement": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/urgence-sanitaire-hebergement/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Urgence sanitaire Covid 19 - Hébergement", + "toodego:page": True, + "template-name": "combo/json/urgence-sanitaire.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "urgence-sanitaire-quotidien": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/urgence-sanitaire-quotidien/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Urgence sanitaire Covid 19 - Services au quotidien", + "toodego:page": True, + "template-name": "combo/json/urgence-sanitaire.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "commerce-animaux-jardin-bricolage": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-animaux-jardin-bricolage/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Commerce - Animaux jardin bricolage", + "toodego:page": True, + "template-name": "combo/json/commerce.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "commerce-autres-activites": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-autres-activites/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Commerce - Autres activités", + "toodego:page": True, + "template-name": "combo/json/commerce.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "commerce-deco-meubles": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-deco-meubles/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Commerce - Déco meubles", + "toodego:page": True, + "template-name": "combo/json/commerce.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "commerce-fleuriste": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-fleuriste/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Commerce - Fleuriste", + "toodego:page": True, + "template-name": "combo/json/commerce.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "commerce-jeux-jouets": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-jeux-jouets/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Commerce - Jeux jouets", + "toodego:page": True, + "template-name": "combo/json/commerce.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "commerce-librairie": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-librairie/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Commerce - Librairie", + "toodego:page": True, + "template-name": "combo/json/commerce.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "commerce-mode": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-mode/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Commerce - Mode", + "toodego:page": True, + "template-name": "combo/json/commerce.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "commerce-restauration": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-restauration/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Commerce - Restauration", + "toodego:page": True, + "template-name": "combo/json/commerce.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "commerce-soins-institut-beaute": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-soins-institut-beaute/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Commerce - Soins institut beauté", + "toodego:page": True, + "template-name": "combo/json/commerce.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "commerce-sport-loisirs": { + "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-sport-loisirs/?property:gid={{gid}}", + "cache_duration": 86400, + "force_async": False, + "name": "Commerce - Sport loisirs", + "toodego:page": True, + "template-name": "combo/json/commerce.html", + "form": [{"varname": "gid", "type": "string", "label": "gid"}], + }, + "rsj-a-traiter": { + "url": "{{eservices_url}}api/forms/?limit={% firstof limit 100 %}{% if category_id %}&category_id={{ category_id }}{% endif %}&NameID={{user_nameid}}", + "cache_duration": 120, + "name": "Demandes à traiter (RSJ)", + "form": [ + {"varname": "limit", "type": "string", "label": "Nombre max de demandes"}, + {"varname": "category_id", "type": "string", "label": "Identifiant de la catégorie"}, + ], + }, + "rsj-fiche": { + "url": "{{eservices_url}}api/cards/jeunes-rsa/{{jeunes_rsa_id}}/", + "name": "Fiche RSJ", + "cache_duration": 120, + }, + "caluire-famille": { + "cache_duration": 30, + "force_async": True, + "name": "Caluire-et-Cuire - Teamnet Axel: Infos famille", + "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/family_info?NameID={{ user_nameid }}", + "form": [{"label": "Identifiant du connecteur", "varname": "slug", "required": True}], + }, + "caluire-responsables": { + "cache_duration": 30, + "force_async": True, + "name": "Caluire-et-Cuire - Teamnet Axel: Infos responsables", + "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/family_info?NameID={{ user_nameid }}", + "form": [{"label": "Identifiant du connecteur", "varname": "slug", "required": True}], + }, + "caluire-liste-enfants": { + "cache_duration": 30, + "force_async": True, + "name": "Caluire-et-Cuire - Teamnet Axel: Liste des enfants (repeat)", + "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/children_info?NameID={{ user_nameid }}", + "make_global": "list_children", + "form": [{"label": "Identifiant du connecteur", "varname": "slug", "required": True}], + }, + "caluire-enfant": { + "cache_duration": 0, + "force_async": True, + "name": "Caluire-et-Cuire - Teamnet Axel: Enfant (repeat)", + "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/child_info?NameID={{ user_nameid }}&idpersonne={{ list_children.data|get:repeat_index|get:'id' }}", + "repeat": "{{ list_children.data|length }}", + "additional-data": [ + { + "key": "schooling", + "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/child_schooling_info?" + "NameID={{ user_nameid }}&idpersonne={{ list_children.data|get:repeat_index|get:'id' }}&schooling_date={% now 'Y-m-d' %}", + }, + { + "key": "activities", + "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/child_activities_info?" + "NameID={{ user_nameid }}&idpersonne={{ list_children.data|get:repeat_index|get:'id' }}&schooling_date={% now 'Y-m-d' %}", + }, + ], + "form": [ + {"label": "Identifiant du connecteur", "varname": "slug", "required": True}, + ], + }, + "caluire-enfant-detail": { + "cache_duration": 30, + "force_async": True, + "name": "Caluire-et-Cuire - Teamnet Axel: Enfant", + "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/child_info?NameID={{ user_nameid }}&idpersonne={{ child_id }}", + "form": [ + {"label": "Identifiant du connecteur", "varname": "slug", "required": True}, + ], + }, + "caluire-enfant-prochaines-inscriptions": { + "cache_duration": 0, + "force_async": True, + "name": "Caluire-et-Cuire - Teamnet Axel: Prochaines inscriptions", + "url": "{% now 'n' as current_month %}{% if current_month in '678' %}" + "{{ passerelle_url }}caluire-axel/{{ slug }}/child_activities_info?NameID={{ user_nameid }}&idpersonne={{ child_id }}" + "&schooling_date={% now 'Y' as current_year %}{{ current_year|add:'1' }}-{% now 'm-d' %}{% endif %}", + "form": [ + {"label": "Identifiant du connecteur", "varname": "slug", "required": True}, + ], + }, + "caluire-enfant-agenda": { + "cache_duration": 0, + "force_async": True, + "name": "Caluire-et-Cuire - Teamnet Axel: Agenda", + "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/get_agenda_full?NameID={{ user_nameid }}&idpersonne={{ child_id }}" + "{% now 'Y' as current_year %}{% now 'n' as current_month %}" + "&start_date={% if current_month in '87654321' %}{{ current_year|add:'-1' }}{% else %}{{ current_year }}{% endif %}-09-01" + "&end_date={% if current_month in '87654321' %}{{ current_year }}{% else %}{{ current_year|add:'1' }}{% endif %}-08-31", + "form": [ + {"label": "Identifiant du connecteur", "varname": "slug", "required": True}, + ], + }, + "caluire-enfant-agenda-next-year": { + "cache_duration": 0, + "force_async": True, + "name": "Caluire-et-Cuire - Teamnet Axel: Agenda prochaine année scolaire", + "url": "{% now 'Y' as current_year %}{% now 'n' as current_month %}{% if current_month in '678' %}" + "{{ passerelle_url }}caluire-axel/{{ slug }}/get_agenda_full?NameID={{ user_nameid }}&idpersonne={{ child_id }}" + "&start_date={% if current_month in '87654321' %}{{ current_year }}{% else %}{{ current_year|add:'1' }}{% endif %}-09-01" + "&end_date={% if current_month in '87654321' %}{{ current_year|add:'1' }}{% else %}{{ current_year|add:'2' }}{% endif %}-08-31{% endif %}", + "form": [ + {"label": "Identifiant du connecteur", "varname": "slug", "required": True}, + ], + }, + } + + PRODUCER_LABELS = { + 'atmo': u'ATMO Auvergne Rhône-Alpes', + 'rnsa': u'RNSA', + 'onlymoov': u'ONLY MOOV', + 'tcl': u'TCL', + 'toodego': u'Toodego', + 'velov': "Velo'v", + 'vivrou': "Vivro", + 'grandlyon': u'Grand Lyon', + 'bluely': "Bluely", + 'citiz-lpa': "Citiz LPA", + 'sncf': "SNCF", + 'effia': "EFFIA", + 'indigo': "Indigo", + 'lpa': "LPA", + 'sas-parc-opera': "SAS Parc Opera", + 'q-park': "Q-Park", + 'unibail': "Unibail", + 'sajr': "sajr", + 'aeroport-saint-exupe': "Aéroport Saint Exupe", + } + + COLLECTIVITY_LABELS = { + "albigny-sur-saone": "Albigny-sur-Saône", + "bron": "Bron", + "cailloux-sur-fontaines": "Cailloux-sur-Fontaines", + "caluire-et-cuire": "Caluire-et-Cuire", + "champagne-au-mont-d-or": "Champagne-au-Mont-d'Or", + "charbonnieres-les-bains": "Charbonnières-les-Bains", + "charly": "Charly", + "chassie": "Chassie", + "collonges-au-mont-d-or": "Collonges-au-Mont-d'Or", + "corbas": "Corbas", + "couzon-au-mont-d-or": "Couzon-au-Mont-d'Or", + "craponne": "Craponne", + "curis-au-mont-d-or": "Curis-au-Mont-d'Or", + "dardilly": "Dardilly", + "decines-charpie": "Décines-Charpie", + "ecully": "Écully", + "feyzin": "Feyzin", + "fleurieu-sur-saone": "Fleurieu-sur-Saône", + "fontaines-saint-martin": "Fontaines-Saint-Martin", + "fontaines-sur-saone": "Fontaines-sur-Saône", + "francheville": "Francheville", + "genay": "Genay", + "givors": "Givors", + "grigny": "Grigny", + "irigny": "Irigny", + "jonage": "Jonage", + "la-mulatiere": "La Mulatière", + "la-tour-de-salvagny": "La Tour de Salvagny", + "limonest": "Limonest", + "lissie": "Lissie", + "lyon": "Lyon", + "marcy-l-etoile": "Marcy-l'Étoile", + "meyzie": "Meyzie", + "mions": "Mions", + "montanay": "Montanay", + "neuville-sur-saone": "Neuville-sur-Saône", + "oullins": "Oullins", + "pierre-benite": "Pierre-Bénite", + "poleymieux-au-mont-d-or": "Poleymieux-au-Mont-d'Or", + "quincieux": "Quincieux", + "rillieux-la-pape": "Rillieux-la-Pape", + "rochetaillee-sur-saone": "Rochetaillée-sur-Saône", + "saint-cyr-au-mont-d-or": "Saint-Cyr-au-Mont-d'Or", + "saint-didier-au-mont-d-or": "Saint-Didier-au-Mont-d'Or", + "saint-fons": "Saint-Fons", + "saint-genis-laval": "Saint-Genis-Laval", + "saint-genis-les-ollieres": "Saint-Genis-les-Ollières", + "saint-germain-au-mont-d-or": "Saint-Germain-au-Mont-d'Or", + "saint-priest": "Saint-Priest", + "sainte-foy-les-lyon": "Sainte-Foy-lès-Lyon", + "sathonay-camp": "Sathonay-Camp", + "sathonay-village": "Sathonay-Village", + "solaize": "Solaize", + "st-romain-au-mont-d-or": "Saint-Romain-au-Mont-d'Or", + "tassin-la-demi-lune": "Tassin-la-Demi-Lune", + "vaulx-en-velin": "Vaulx-en-Velin", + "venissieux": "Venissieux", + "vernaison": "Vernaison", + "villeurbanne": "Villeurbanne", + } + + PRODUCER_LABELS.update(COLLECTIVITY_LABELS) + + COMBO_ASSET_SLOTS = self.settings_json.get('COMBO_ASSET_SLOTS.update') or {} + for producer, producer_label in PRODUCER_LABELS.items(): + COMBO_ASSET_SLOTS['logo:%s' % producer] = {'label': u'Logo %s' % producer_label} + + # add lyon as used by cart@ds + for arrondissement in ['1er'] + ['%seme' % x for x in range(2, 10)]: + COMBO_ASSET_SLOTS['logo:lyon-%s' % arrondissement] = { + 'label': u'Logo Lyon %s' % arrondissement, + } + + tiles = [ + ('air', "Qualité de l'air"), + ('bibliotheque', "Bibliothèque"), + ('commerce-animaux-jardin-bricolage', 'Commerce - Animaux jardin bricolage'), + ('commerce-autres-activites', 'Commerce - Autres activités'), + ('commerce-deco-meubles', 'Commerce - Déco meubles'), + ('commerce-fleuriste', 'Commerce - Fleuriste'), + ('commerce-jeux-jouets', 'Commerce - Jeux jouets'), + ('commerce-librairie', 'Commerce - Librairie'), + ('commerce-mode', 'Commerce - Mode'), + ('commerce-restauration', 'Commerce - Restauration'), + ('commerce-soins-institut-beaute', 'Commerce - Soins institut beauté'), + ('commerce-sport-loisirs', 'Commerce - Sport loisirs'), + ('covoiturage', "Aire de covoiturage"), + ('decheterie', "Déchèterie"), + ('donnerie', "Donnerie"), + ('mairie', "Mairie"), + ('mdr', "Maison du Rhône"), + ('parc-velo', "Parc vélo"), + ('piscine', "Piscine"), + ('pollen', "Pollen"), + ('silo-a-verre', u'Silo à verre'), + ('taxi', "Taxi"), + ('tcl', "TCL"), + ('velov', "Velo'v"), + ('parkingtr', "Parking"), + ('autopartage', "Autopartage"), + ('evenement-routier', "Événement routier"), + ('pmr', "Stationnement PMR"), + ('toilette', "Toilette publique"), + ('urgence-sanitaire-soins', 'Urgence sanitaire Covid 19 - Accès aux soins'), + ('urgence-sanitaire-alimentation', 'Urgence sanitaire Covid 19 - Alimentation'), + ('urgence-sanitaire-hebergement', 'Urgence sanitaire Covid 19 - Hébergement'), + ('urgence-sanitaire-quotidien', 'Urgence sanitaire Covid 19 - Services au quotidien'), + ] + + for tile, tile_label in tiles: + COMBO_ASSET_SLOTS['picture:%s' % tile] = {'label': u'Photographie %s' % tile_label} + if tile not in ('taxi', 'tcl', 'velov'): + COMBO_ASSET_SLOTS['picture:banner:%s' % tile] = { + 'label': u'Photographie/bannière %s' % tile_label + } + + SESSION_EXPIRE_AT_BROWSER_CLOSE = False + + self.settings_json.update(locals()) + + def import_extra_settings(self): + with open(self.extra_settings_filepath) as fd: + settings_json = json.load(fd) + for k, v in settings_json.items(): + if isinstance(self.settings_json.get(k), dict): + self.settings_json[k].update(v) + else: + self.settings_json[k] = v + + def set_no_logs(self): + # change json cells to never log + for cell in self.settings_json['JSON_CELL_TYPES'].values(): + cell['log_errors'] = False + for add in cell.get('additional-data') or []: + add['log_errors'] = False diff --git a/debian/50gnm.py b/debian/50gnm.py index 467f79d..da4c4e9 100644 --- a/debian/50gnm.py +++ b/debian/50gnm.py @@ -4,656 +4,6 @@ if not 'combo_plugin_gnm' in INSTALLED_APPS: INSTALLED_APPS += ('combo_plugin_gnm',) TENANT_APPS += ('combo_plugin_gnm',) -MELLON_ADD_AUTHNREQUEST_NEXT_URL_EXTENSION = True - -COMBO_MAP_TILE_URLTEMPLATE = "https://tiles.entrouvert.org/hdm/{z}/{x}/{y}.png" -COMBO_MAP_ATTRIBUTION = "© OpenStreetMap" -COMBO_GEOCODING_SERVICE = 'https://nominatim.entrouvert.org' - -JSON_CELL_TYPES = { - "velov": { - "url": "https://%(data_username)s:%(data_password)s@download.data.grandlyon.com/ws/rdata/jcd_jcdecaux.jcdvelov/all.json?field=gid&value=[gid]" - % DATA_CREDENTIALS, - "name": u"Velov", - "cache_duration": 60, - "force_async": False, - "auto_refresh": 90, - "form": [{"varname": "gid", "type": "string", "label": "GID de la station"}], - }, - "taxi": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/taxi/?property:gid={{gid}}", - "name": u"Station de taxi", - "cache_duration": 86400, - "force_async": False, - "form": [{"varname": "gid", "type": "string", "label": "GID de la station"}], - }, - "mdr": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/mdr/?property:identifiant={{identifiant}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Maison de la Métropole de Lyon", - "toodego:page": True, - "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], - }, - "piscine": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/piscine/?property:identifiant={{identifiant}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Piscine de la Métropole de Lyon", - "toodego:page": True, - "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], - }, - "mairie": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/mairie/?property:identifiant={{identifiant}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Mairie", - "toodego:page": True, - "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], - }, - "decheterie": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/decheterie/?property:identifiant={{identifiant}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Déchèterie", - "toodego:page": True, - "toodego:page-title-template": "Déchèterie {{properties.nom}}", - "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], - }, - "donnerie": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/donnerie/?property:identifiant={{identifiant}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Donnerie", - "toodego:page": True, - "toodego:page-title-template": "Donnerie {{properties.nom}}", - "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], - }, - "bibliotheque": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/bibliotheque/?property:identifiant={{identifiant}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Bibliothèque", - "toodego:page": True, - "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], - }, - "aire-de-covoiturage": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/aire-de-covoiturage/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Aire de covoiturage", - "form": [{"varname": "gid", "type": "string", "label": "Identifiant"}], - }, - "airquality": { - "url": "{% if q_lat or lat %}http://api.atmo-aura.fr/partenaires/indice_request?api_token=6df2b0b505cc73c5545467758827458e&longitude={% firstof q_lon lon %}&latitude={% firstof q_lat lat %}{% endif %}", - "cache_duration": 300, - "force_async": False, - "name": u"Qualité de l'air", - "form": [ - { - "varname": "lat", - "type": "string", - "label": "Latitude", - "required": False, - }, - { - "varname": "lon", - "type": "string", - "label": "Longitude", - "required": False, - }, - ], - "additional-data": [ - { - "key": "air2go", - "url": "{% if q_lat or lat %}http://api.atmo-aura.fr/partenaires/indice_request?api_token=6df2b0b505cc73c5545467758827458e&longitude={% firstof q_lon lon %}&latitude={% firstof q_lat lat %}{% endif %}", - }, - { - "key": "nominatim", - "url": "{% if q_lat or lat %}{{passerelle_url}}base-adresse/nominatim/reverse?lat={% firstof q_lat lat %}&lon={% firstof q_lon lon %}&format=json{% endif %}", - "cache_duration": 3600, - }, - { - "key": "places", - "url": "{% if user_nameid %}{{ passerelle_url }}jsondatastore/lieux-favoris/data/?name_id={{user_nameid}}{% endif %}", - }, - { - "key": "place_geoloc", - "url": "{% if places %}{{ passerelle_url }}base-adresse/nominatim/search?q={{ places.data.0.text }}&format=json{% endif %}", - "cache_duration": 3600, - }, - { - "key": "place2_geoloc", - "url": "{% if places|length > 1 %}{{ passerelle_url }}base-adresse/nominatim/search?q={{ places.data.1.text }}&format=json{% endif %}", - "cache_duration": 3600, - }, - ], - "actions": { - "geocode": { - "url": "{{ passerelle_url }}base-adresse/nominatim/search?q={{ q }}&format=json", - "method": "get", - "response": "raw", - } - }, - }, - "pollen": { - "url": "https://download.data.grandlyon.com/ws/rdata/rnsa_reseau_aerobio.rnsabulletin/all.json", - "cache_duration": 300, - "force_async": False, - "name": u"Info Pollen", - "additional-data": [ - { - "key": "syntheses", - "url": "https://download.data.grandlyon.com/ws/rdata/rnsa_reseau_aerobio.rnsabulletin/all.json?field=type&value=Synthese", - } - ], - }, - "places": { - "url": "{{passerelle_url}}jsondatastore/lieux-favoris/data/?name_id={{user_nameid}}", - "name": u"Lieux favoris", - "force_async": False, - "cache_duration": 600, - "additional-data": [{"key": "userdata", "url": "{{idp_url}}api/users/{{user_nameid}}"}], - "actions": { - "create": { - "url": "{{passerelle_url}}jsondatastore/lieux-favoris/data/create?name_id={{user_nameid}}" - }, - "update": { - "url": "{{passerelle_url}}jsondatastore/lieux-favoris/data/{{id}}/?name_id={{user_nameid}}" - }, - "delete": { - "url": "{{passerelle_url}}jsondatastore/lieux-favoris/data/{{id}}/delete?name_id={{user_nameid}}" - }, - }, - }, - "silo-a-verre": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/silo-a-verre/?property:identifiant={{identifiant}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Silo à verre", - "form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}], - }, - "tcl": { - "url": "{{passerelle_url}}tcl/tcl/stop/{{id}}", - "auto_refresh": 25, - "cache_duration": 10, - "force_async": False, - "name": u"Arrêt TCL", - "form": [{"varname": "id", "type": "string", "label": "Identifiant"}], - }, - "goto": { - "url": "{% load l10n %}{% localize off %}{% if lat1 %}{{cityway_api_url}}api/journeyplanner/opt/PlanTrips/json?DepartureType=COORDINATES&DepartureLatitude={{lat1}}&DepartureLongitude={{lng1}}&ArrivalType=COORDINATES&ArrivalLatitude={{lat2}}&ArrivalLongitude={{lng2}}&Date={{date}}&DateType=DEPARTURE&TripModes={{tripmode}}&Algorithm=FASTEST&BikeSecurityLevel=None&BikeSpeed=12&WalkSpeed=4&MaxCarDistance=100&MaxBikeDistance=100&MaxWalkDistance=3000&AvoidDisruptions=1&StopToPlaceCar=1&SpecificOptions=GetOn;3|GetOff;4|TinyDistance;300|VLS;0|CARSHARING;0&UserId={% firstof cityway_api_userid 'toodego' %}&user_key={{cityway_api_userkey}}{% endif %}{% endlocalize %}", - "cache_duration": 60, - "force_async": False, - "name": u"M'y rendre", - "loading-message": u'Calcul…', - "varnames": ["lat1", "lng1", "lat2", "lng2", "date", "to"], - "form": [ - {"varname": "tripmode", "type": "string", "label": "Mode de transport (WALK, BIKE, PT, CAR)"} - ], - }, - "cut-profile": { - "url": "{{idp_url}}api/users/{{user_nameid}}/", - "name": "Profil CUT", - "auto_refresh": 60, - }, - "profile-info": {"url": "{{idp_url}}api/users/{{user_nameid}}/", "name": "Infos de profil"}, - "suggestions": { - "name": "Suggestions", - "url": "{{idp_url}}api/users/{{user_nameid}}", - "force_async": True, - "loading-message": "Assemblage en cours, quelques secondes…", - "additional-data": [ - { - "key": "places", - "url": "{{passerelle_url}}jsondatastore/lieux-favoris/data/?name_id={{user_nameid}}", - } - ], - }, - "alerte-qualite-de-l-air": { - "url": "{{passerelle_url}}feeds/alertes-qualite-de-lair/json", - "cache_duration": 600, - "force_async": True, - "name": u"Alerte qualité de l'air", - }, - "mairie-usager": { - "name": "Mairie de l'usager", - "url": "{{idp_url}}api/users/{{user_nameid}}/", - "form": [{"varname": "text", "type": "text", "label": "Texte"}], - }, - "group-title": { - "name": "Intertitre", - "url": "{{}}", - "form": [{"varname": "text", "type": "text", "label": "Texte"}], - }, - "stats": { - "name": "Statistiques tuiles", - "url": "{{portal_url}}api/dashboard/tile-stats/", - }, - "parkingtr": { - "url": "https://%(data_username)s:%(data_password)s@download.data.grandlyon.com/wfs/rdata?SERVICE=WFS&VERSION=2.0.0&outputformat=GEOJSON&request=GetFeature&typename=pvo_patrimoine_voirie.pvoparkingtr&filter=pkgid[pkgid]" - % DATA_CREDENTIALS, - "cache_duration": 86400, - "force_async": False, - "name": u"Parking", - "form": [{"varname": "pkgid", "type": "string", "label": "Identifiant"}], - }, - "parc-velo": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/parc-velo/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Parc de stationnement vélos", - "form": [{"varname": "gid", "type": "string", "label": "Identifiant"}], - }, - "autopartage": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/autopartage/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Autopartage", - "form": [{"varname": "gid", "type": "string", "label": "Identifiant"}], - }, - "stationnement-pmr": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/stationnement-pmr/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Stationnement réglementé pour les PMR", - "form": [{"varname": "gid", "type": "string", "label": "Identifiant"}], - }, - "toilette": { - "url": "{{passerelle_url}}opengis/data-grandlyon-general/query/toilette/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": u"Toilette publique", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "evenement-routier": { - "url": "https://%(data_username)s:%(data_password)s@download.data.grandlyon.com/wfs/rdata?SERVICE=WFS&VERSION=2.0.0&outputformat=GEOJSON&request=GetFeature&typename=pvo_patrimoine_voirie.pvoevenement&filter=id[id]" - % DATA_CREDENTIALS, - "cache_duration": 86400, - "force_async": False, - "name": u"Evenement routier", - "form": [{"varname": "id", "type": "string", "label": "Identifiant"}], - }, - "cartads-dossiers": { - "url": "{{passerelle_url}}grandlyon-cartads-cs/{{slug}}/files?name_id={{user_nameid}}", - "cache_duration": 0, - "force_async": True, - "name": u"Dossiers Cart@DS", - "form": [{"varname": "slug", "type": "string", "label": "Slug du connecteur"}], - "actions": { - "unsubscribe": { - "url": "{{passerelle_url}}grandlyon-cartads-cs/{{slug}}/unsubscribe?name_id={{user_nameid}}", - }, - }, - }, - "urgence-sanitaire-soins": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/urgence-sanitaire-soins/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Urgence sanitaire Covid 19 - Accès aux soins", - "toodego:page": True, - "template-name": "combo/json/urgence-sanitaire.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "urgence-sanitaire-alimentation": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/urgence-sanitaire-alimentation/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Urgence sanitaire Covid 19 - Alimentation", - "toodego:page": True, - "template-name": "combo/json/urgence-sanitaire.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "urgence-sanitaire-hebergement": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/urgence-sanitaire-hebergement/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Urgence sanitaire Covid 19 - Hébergement", - "toodego:page": True, - "template-name": "combo/json/urgence-sanitaire.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "urgence-sanitaire-quotidien": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/urgence-sanitaire-quotidien/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Urgence sanitaire Covid 19 - Services au quotidien", - "toodego:page": True, - "template-name": "combo/json/urgence-sanitaire.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "commerce-animaux-jardin-bricolage": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-animaux-jardin-bricolage/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Commerce - Animaux jardin bricolage", - "toodego:page": True, - "template-name": "combo/json/commerce.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "commerce-autres-activites": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-autres-activites/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Commerce - Autres activités", - "toodego:page": True, - "template-name": "combo/json/commerce.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "commerce-deco-meubles": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-deco-meubles/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Commerce - Déco meubles", - "toodego:page": True, - "template-name": "combo/json/commerce.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "commerce-fleuriste": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-fleuriste/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Commerce - Fleuriste", - "toodego:page": True, - "template-name": "combo/json/commerce.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "commerce-jeux-jouets": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-jeux-jouets/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Commerce - Jeux jouets", - "toodego:page": True, - "template-name": "combo/json/commerce.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "commerce-librairie": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-librairie/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Commerce - Librairie", - "toodego:page": True, - "template-name": "combo/json/commerce.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "commerce-mode": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-mode/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Commerce - Mode", - "toodego:page": True, - "template-name": "combo/json/commerce.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "commerce-restauration": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-restauration/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Commerce - Restauration", - "toodego:page": True, - "template-name": "combo/json/commerce.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "commerce-soins-institut-beaute": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-soins-institut-beaute/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Commerce - Soins institut beauté", - "toodego:page": True, - "template-name": "combo/json/commerce.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "commerce-sport-loisirs": { - "url": "{{passerelle_url}}opengis/data-grandlyon-rdata/query/commerce-sport-loisirs/?property:gid={{gid}}", - "cache_duration": 86400, - "force_async": False, - "name": "Commerce - Sport loisirs", - "toodego:page": True, - "template-name": "combo/json/commerce.html", - "form": [{"varname": "gid", "type": "string", "label": "gid"}], - }, - "rsj-a-traiter": { - "url": "{{eservices_url}}api/forms/?limit={% firstof limit 100 %}{% if category_id %}&category_id={{ category_id }}{% endif %}&NameID={{user_nameid}}", - "cache_duration": 120, - "name": "Demandes à traiter (RSJ)", - "form": [ - {"varname": "limit", "type": "string", "label": "Nombre max de demandes"}, - {"varname": "category_id", "type": "string", "label": "Identifiant de la catégorie"}, - ], - }, - "rsj-fiche": { - "url": "{{eservices_url}}api/cards/jeunes-rsa/{{jeunes_rsa_id}}/", - "name": "Fiche RSJ", - "cache_duration": 120, - }, - "caluire-famille": { - "cache_duration": 30, - "force_async": True, - "name": "Caluire-et-Cuire - Teamnet Axel: Infos famille", - "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/family_info?NameID={{ user_nameid }}", - "form": [{"label": "Identifiant du connecteur", "varname": "slug", "required": True}], - }, - "caluire-responsables": { - "cache_duration": 30, - "force_async": True, - "name": "Caluire-et-Cuire - Teamnet Axel: Infos responsables", - "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/family_info?NameID={{ user_nameid }}", - "form": [{"label": "Identifiant du connecteur", "varname": "slug", "required": True}], - }, - "caluire-liste-enfants": { - "cache_duration": 30, - "force_async": True, - "name": "Caluire-et-Cuire - Teamnet Axel: Liste des enfants (repeat)", - "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/children_info?NameID={{ user_nameid }}", - "make_global": "list_children", - "form": [{"label": "Identifiant du connecteur", "varname": "slug", "required": True}], - }, - "caluire-enfant": { - "cache_duration": 0, - "force_async": True, - "name": "Caluire-et-Cuire - Teamnet Axel: Enfant (repeat)", - "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/child_info?NameID={{ user_nameid }}&idpersonne={{ list_children.data|get:repeat_index|get:'id' }}", - "repeat": "{{ list_children.data|length }}", - "additional-data": [ - { - "key": "schooling", - "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/child_schooling_info?" - "NameID={{ user_nameid }}&idpersonne={{ list_children.data|get:repeat_index|get:'id' }}&schooling_date={% now 'Y-m-d' %}", - }, - { - "key": "activities", - "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/child_activities_info?" - "NameID={{ user_nameid }}&idpersonne={{ list_children.data|get:repeat_index|get:'id' }}&schooling_date={% now 'Y-m-d' %}", - }, - ], - "form": [ - {"label": "Identifiant du connecteur", "varname": "slug", "required": True}, - ], - }, - "caluire-enfant-detail": { - "cache_duration": 30, - "force_async": True, - "name": "Caluire-et-Cuire - Teamnet Axel: Enfant", - "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/child_info?NameID={{ user_nameid }}&idpersonne={{ child_id }}", - "form": [ - {"label": "Identifiant du connecteur", "varname": "slug", "required": True}, - ], - }, - "caluire-enfant-prochaines-inscriptions": { - "cache_duration": 0, - "force_async": True, - "name": "Caluire-et-Cuire - Teamnet Axel: Prochaines inscriptions", - "url": "{% now 'n' as current_month %}{% if current_month in '678' %}" - "{{ passerelle_url }}caluire-axel/{{ slug }}/child_activities_info?NameID={{ user_nameid }}&idpersonne={{ child_id }}" - "&schooling_date={% now 'Y' as current_year %}{{ current_year|add:'1' }}-{% now 'm-d' %}{% endif %}", - "form": [ - {"label": "Identifiant du connecteur", "varname": "slug", "required": True}, - ], - }, - "caluire-enfant-agenda": { - "cache_duration": 0, - "force_async": True, - "name": "Caluire-et-Cuire - Teamnet Axel: Agenda", - "url": "{{ passerelle_url }}caluire-axel/{{ slug }}/get_agenda_full?NameID={{ user_nameid }}&idpersonne={{ child_id }}" - "{% now 'Y' as current_year %}{% now 'n' as current_month %}" - "&start_date={% if current_month in '87654321' %}{{ current_year|add:'-1' }}{% else %}{{ current_year }}{% endif %}-09-01" - "&end_date={% if current_month in '87654321' %}{{ current_year }}{% else %}{{ current_year|add:'1' }}{% endif %}-08-31", - "form": [ - {"label": "Identifiant du connecteur", "varname": "slug", "required": True}, - ], - }, - "caluire-enfant-agenda-next-year": { - "cache_duration": 0, - "force_async": True, - "name": "Caluire-et-Cuire - Teamnet Axel: Agenda prochaine année scolaire", - "url": "{% now 'Y' as current_year %}{% now 'n' as current_month %}{% if current_month in '678' %}" - "{{ passerelle_url }}caluire-axel/{{ slug }}/get_agenda_full?NameID={{ user_nameid }}&idpersonne={{ child_id }}" - "&start_date={% if current_month in '87654321' %}{{ current_year }}{% else %}{{ current_year|add:'1' }}{% endif %}-09-01" - "&end_date={% if current_month in '87654321' %}{{ current_year|add:'1' }}{% else %}{{ current_year|add:'2' }}{% endif %}-08-31{% endif %}", - "form": [ - {"label": "Identifiant du connecteur", "varname": "slug", "required": True}, - ], - }, -} - -PRODUCER_LABELS = { - 'atmo': u'ATMO Auvergne Rhône-Alpes', - 'rnsa': u'RNSA', - 'onlymoov': u'ONLY MOOV', - 'tcl': u'TCL', - 'toodego': u'Toodego', - 'velov': u"Velo'v", - 'vivrou': u"Vivrou", - 'grandlyon': u'Grand Lyon', - 'bluely': u"Bluely", - 'citiz-lpa': u"Citiz LPA", - 'sncf': u"SNCF", - 'effia': u"EFFIA", - 'indigo': u"Indigo", - 'lpa': u"LPA", - 'sas-parc-opera': u"SAS Parc Opera", - 'q-park': u"Q-Park", - 'unibail': u"Unibail", - 'sajr': u"sajr", - 'aeroport-saint-exupe': u"Aéroport Saint Exupe", -} - -COLLECTIVITY_LABELS = { - "albigny-sur-saone": u"Albigny-sur-Saône", - "bron": u"Bron", - "cailloux-sur-fontaines": u"Cailloux-sur-Fontaines", - "caluire-et-cuire": u"Caluire-et-Cuire", - "champagne-au-mont-d-or": u"Champagne-au-Mont-d'Or", - "charbonnieres-les-bains": u"Charbonnières-les-Bains", - "charly": u"Charly", - "chassieu": u"Chassieu", - "collonges-au-mont-d-or": u"Collonges-au-Mont-d'Or", - "corbas": u"Corbas", - "couzon-au-mont-d-or": u"Couzon-au-Mont-d'Or", - "craponne": u"Craponne", - "curis-au-mont-d-or": u"Curis-au-Mont-d'Or", - "dardilly": u"Dardilly", - "decines-charpieu": u"Décines-Charpieu", - "ecully": u"Écully", - "feyzin": u"Feyzin", - "fleurieu-sur-saone": u"Fleurieu-sur-Saône", - "fontaines-saint-martin": u"Fontaines-Saint-Martin", - "fontaines-sur-saone": u"Fontaines-sur-Saône", - "francheville": u"Francheville", - "genay": u"Genay", - "givors": u"Givors", - "grigny": u"Grigny", - "irigny": u"Irigny", - "jonage": u"Jonage", - "la-mulatiere": u"La Mulatière", - "la-tour-de-salvagny": u"La Tour de Salvagny", - "limonest": u"Limonest", - "lissieu": u"Lissieu", - "lyon": u"Lyon", - "marcy-l-etoile": u"Marcy-l'Étoile", - "meyzieu": u"Meyzieu", - "mions": u"Mions", - "montanay": u"Montanay", - "neuville-sur-saone": u"Neuville-sur-Saône", - "oullins": u"Oullins", - "pierre-benite": u"Pierre-Bénite", - "poleymieux-au-mont-d-or": u"Poleymieux-au-Mont-d'Or", - "quincieux": u"Quincieux", - "rillieux-la-pape": u"Rillieux-la-Pape", - "rochetaillee-sur-saone": u"Rochetaillée-sur-Saône", - "saint-cyr-au-mont-d-or": u"Saint-Cyr-au-Mont-d'Or", - "saint-didier-au-mont-d-or": u"Saint-Didier-au-Mont-d'Or", - "saint-fons": u"Saint-Fons", - "saint-genis-laval": u"Saint-Genis-Laval", - "saint-genis-les-ollieres": u"Saint-Genis-les-Ollières", - "saint-germain-au-mont-d-or": u"Saint-Germain-au-Mont-d'Or", - "saint-priest": u"Saint-Priest", - "sainte-foy-les-lyon": u"Sainte-Foy-lès-Lyon", - "sathonay-camp": u"Sathonay-Camp", - "sathonay-village": u"Sathonay-Village", - "solaize": u"Solaize", - "st-romain-au-mont-d-or": u"Saint-Romain-au-Mont-d'Or", - "tassin-la-demi-lune": u"Tassin-la-Demi-Lune", - "vaulx-en-velin": u"Vaulx-en-Velin", - "venissieux": u"Venissieux", - "vernaison": u"Vernaison", - "villeurbanne": u"Villeurbanne", -} - -PRODUCER_LABELS.update(COLLECTIVITY_LABELS) - -for producer, producer_label in PRODUCER_LABELS.items(): - COMBO_ASSET_SLOTS['logo:%s' % producer] = {'label': u'Logo %s' % producer_label} - -# add lyon as used by cart@ds -for arrondissement in ['1er'] + ['%seme' % x for x in range(2, 10)]: - COMBO_ASSET_SLOTS['logo:lyon-%s' % arrondissement] = { - 'label': u'Logo Lyon %s' % arrondissement, - } - -tiles = [ - ('air', u"Qualité de l'air"), - ('bibliotheque', u"Bibliothèque"), - ('commerce-animaux-jardin-bricolage', 'Commerce - Animaux jardin bricolage'), - ('commerce-autres-activites', 'Commerce - Autres activités'), - ('commerce-deco-meubles', 'Commerce - Déco meubles'), - ('commerce-fleuriste', 'Commerce - Fleuriste'), - ('commerce-jeux-jouets', 'Commerce - Jeux jouets'), - ('commerce-librairie', 'Commerce - Librairie'), - ('commerce-mode', 'Commerce - Mode'), - ('commerce-restauration', 'Commerce - Restauration'), - ('commerce-soins-institut-beaute', 'Commerce - Soins institut beauté'), - ('commerce-sport-loisirs', 'Commerce - Sport loisirs'), - ('covoiturage', u"Aire de covoiturage"), - ('decheterie', u"Déchèterie"), - ('donnerie', u"Donnerie"), - ('mairie', u"Mairie"), - ('mdr', u"Maison du Rhône"), - ('parc-velo', u"Parc vélo"), - ('piscine', u"Piscine"), - ('pollen', u"Pollen"), - ('silo-a-verre', u'Silo à verre'), - ('taxi', u"Taxi"), - ('tcl', u"TCL"), - ('velov', u"Velo'v"), - ('parkingtr', u"Parking"), - ('autopartage', u"Autopartage"), - ('evenement-routier', u"Événement routier"), - ('pmr', u"Stationnement PMR"), - ('toilette', u"Toilette publique"), - ('urgence-sanitaire-soins', 'Urgence sanitaire Covid 19 - Accès aux soins'), - ('urgence-sanitaire-alimentation', 'Urgence sanitaire Covid 19 - Alimentation'), - ('urgence-sanitaire-hebergement', 'Urgence sanitaire Covid 19 - Hébergement'), - ('urgence-sanitaire-quotidien', 'Urgence sanitaire Covid 19 - Services au quotidien'), -] - -for tile, tile_label in tiles: - COMBO_ASSET_SLOTS['picture:%s' % tile] = {'label': u'Photographie %s' % tile_label} - if tile not in ('taxi', 'tcl', 'velov'): - COMBO_ASSET_SLOTS['picture:banner:%s' % tile] = {'label': u'Photographie/bannière %s' % tile_label} - import memcache memcache.SERVER_MAX_VALUE_LENGTH = 10 * 1024 * 1024 - -SESSION_EXPIRE_AT_BROWSER_CLOSE = False diff --git a/debian/python3-combo-plugin-gnm.cron.hourly b/debian/python3-combo-plugin-gnm.cron.hourly new file mode 100755 index 0000000..35bfa1e --- /dev/null +++ b/debian/python3-combo-plugin-gnm.cron.hourly @@ -0,0 +1,3 @@ +#! /bin/sh + +/sbin/runuser -u combo /usr/bin/combo-manage -- tenant_command gnm_update_settings --all-tenants