mark json entries to be used as tiles (#68618)

This commit is contained in:
Frédéric Péters 2022-09-01 13:36:47 +02:00
parent 9488236909
commit b7456da8d9
1 changed files with 54 additions and 42 deletions

View File

@ -45,7 +45,6 @@ class Command(BaseCommand):
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)
@ -69,6 +68,7 @@ class Command(BaseCommand):
"cache_duration": 60,
"force_async": False,
"auto_refresh": 90,
"toodego:tile": True,
"form": [{"varname": "gid", "type": "string", "label": "GID de la station"}],
},
"taxi": {
@ -76,6 +76,7 @@ class Command(BaseCommand):
"name": "Station de taxi",
"cache_duration": 86400,
"force_async": False,
"toodego:tile": True,
"form": [{"varname": "gid", "type": "string", "label": "GID de la station"}],
},
"mdr": {
@ -84,6 +85,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Maison de la Métropole de Lyon",
"toodego:page": True,
"toodego:tile": True,
"form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}],
},
"piscine": {
@ -92,6 +94,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Piscine de la Métropole de Lyon",
"toodego:page": True,
"toodego:tile": True,
"form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}],
},
"mairie": {
@ -100,6 +103,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Mairie",
"toodego:page": True,
"toodego:tile": True,
"form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}],
},
"decheterie": {
@ -109,6 +113,7 @@ class Command(BaseCommand):
"name": "Déchèterie",
"toodego:page": True,
"toodego:page-title-template": "Déchèterie {{properties.nom}}",
"toodego:tile": True,
"form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}],
},
"donnerie": {
@ -118,6 +123,7 @@ class Command(BaseCommand):
"name": "Donnerie",
"toodego:page": True,
"toodego:page-title-template": "Donnerie {{properties.nom}}",
"toodego:tile": True,
"form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}],
},
"bibliotheque": {
@ -126,6 +132,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Bibliothèque",
"toodego:page": True,
"toodego:tile": True,
"form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}],
},
"aire-de-covoiturage": {
@ -133,6 +140,7 @@ class Command(BaseCommand):
"cache_duration": 86400,
"force_async": False,
"name": "Aire de covoiturage",
"toodego:tile": True,
"form": [{"varname": "gid", "type": "string", "label": "Identifiant"}],
},
"cinema": {
@ -140,6 +148,7 @@ class Command(BaseCommand):
"name": "Cinéma",
"cache_duration": 86400,
"force_async": False,
"toodego:tile": True,
"form": [{"varname": "gid", "type": "string", "label": "GID du cinéma"}],
},
"musee": {
@ -148,6 +157,7 @@ class Command(BaseCommand):
"cache_duration": 86400,
"force_async": False,
"toodego:page": False,
"toodego:tile": True,
"form": [{"varname": "gid", "type": "string", "label": "GID du musée"}],
},
"parc-et-jardin-ponctuel": {
@ -156,6 +166,7 @@ class Command(BaseCommand):
"cache_duration": 86400,
"force_async": False,
"toodego:page": False,
"toodego:tile": True,
"form": [{"varname": "gid", "type": "string", "label": "GID du parc ou jardin"}],
},
"airquality": {
@ -163,6 +174,7 @@ class Command(BaseCommand):
"cache_duration": 300,
"force_async": False,
"name": "Qualité de l'air",
'toodego:tile': 'air',
"form": [
{
"varname": "lat",
@ -215,6 +227,7 @@ class Command(BaseCommand):
"cache_duration": 300,
"force_async": False,
"name": "Info Pollen",
"toodego:tile": True,
"additional-data": [
{
"key": "syntheses",
@ -245,6 +258,7 @@ class Command(BaseCommand):
"cache_duration": 86400,
"force_async": False,
"name": "Silo à verre",
"toodego:tile": True,
"form": [{"varname": "identifiant", "type": "string", "label": "Identifiant"}],
},
"tcl": {
@ -253,6 +267,7 @@ class Command(BaseCommand):
"cache_duration": 10,
"force_async": False,
"name": "Arrêt TCL",
"toodego:tile": True,
"form": [{"varname": "id", "type": "string", "label": "Identifiant"}],
},
"goto": {
@ -314,6 +329,7 @@ class Command(BaseCommand):
"cache_duration": 86400,
"force_async": False,
"name": "Parking",
"toodego:tile": True,
"form": [{"varname": "pkgid", "type": "string", "label": "Identifiant"}],
},
"parc-velo": {
@ -321,6 +337,7 @@ class Command(BaseCommand):
"cache_duration": 86400,
"force_async": False,
"name": "Parc de stationnement vélos",
"toodego:tile": True,
"form": [{"varname": "gid", "type": "string", "label": "Identifiant"}],
},
"autopartage": {
@ -328,6 +345,7 @@ class Command(BaseCommand):
"cache_duration": 86400,
"force_async": False,
"name": "Autopartage",
"toodego:tile": True,
"form": [{"varname": "gid", "type": "string", "label": "Identifiant"}],
},
"stationnement-pmr": {
@ -335,6 +353,7 @@ class Command(BaseCommand):
"cache_duration": 86400,
"force_async": False,
"name": "Stationnement réglementé pour les PMR",
"toodego:tile": "pmr",
"form": [{"varname": "gid", "type": "string", "label": "Identifiant"}],
},
"toilette": {
@ -342,6 +361,7 @@ class Command(BaseCommand):
"cache_duration": 86400,
"force_async": False,
"name": "Toilette publique",
"toodego:tile": True,
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
"evenement-routier": {
@ -350,6 +370,7 @@ class Command(BaseCommand):
"cache_duration": 86400,
"force_async": False,
"name": "Evenement routier",
"toodego:tile": True,
"form": [{"varname": "id", "type": "string", "label": "Identifiant"}],
},
"cartads-dossiers": {
@ -370,6 +391,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Urgence sanitaire Covid 19 - Accès aux soins",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/urgence-sanitaire.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -379,6 +401,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Urgence sanitaire Covid 19 - Alimentation",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/urgence-sanitaire.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -388,6 +411,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Urgence sanitaire Covid 19 - Hébergement",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/urgence-sanitaire.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -397,6 +421,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Urgence sanitaire Covid 19 - Services au quotidien",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/urgence-sanitaire.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -406,6 +431,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Commerce - Animaux jardin bricolage",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/commerce.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -415,6 +441,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Commerce - Autres activités",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/commerce.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -424,6 +451,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Commerce - Déco meubles",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/commerce.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -433,6 +461,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Commerce - Fleuriste",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/commerce.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -442,6 +471,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Commerce - Jeux jouets",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/commerce.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -451,6 +481,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Commerce - Librairie",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/commerce.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -460,6 +491,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Commerce - Mode",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/commerce.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -469,6 +501,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Commerce - Restauration",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/commerce.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -478,6 +511,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Commerce - Soins institut beauté",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/commerce.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -487,6 +521,7 @@ class Command(BaseCommand):
"force_async": False,
"name": "Commerce - Sport loisirs",
"toodego:page": True,
"toodego:tile": True,
"template-name": "combo/json/commerce.html",
"form": [{"varname": "gid", "type": "string", "label": "gid"}],
},
@ -690,52 +725,29 @@ class Command(BaseCommand):
'label': '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', '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': 'Photographie %s' % tile_label}
if tile not in ('taxi', 'tcl', 'velov'):
COMBO_ASSET_SLOTS['picture:banner:%s' % tile] = {
for cell_key, cell_dict in JSON_CELL_TYPES.items():
tile = cell_key
tile_label = cell_dict.get('name')
if cell_dict.get('toodego:tile'):
tile_key = (
cell_dict.get('toodego:tile')
if isinstance(cell_dict.get('toodego:tile'), str)
else cell_key
)
COMBO_ASSET_SLOTS['picture:%s' % tile_key] = {'label': 'Photographie %s' % tile_label}
if cell_dict.get('toodego:page'):
page_key = (
cell_dict.get('toodego:page')
if isinstance(cell_dict.get('toodego:page'), str)
else cell_key
)
COMBO_ASSET_SLOTS['picture:banner:%s' % page_key] = {
'label': 'Photographie/bannière %s' % tile_label
}
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
self.settings_json.update(locals())
self.settings_json.update({k: v for k, v in locals().items() if k[0].isupper()})
def import_extra_settings(self):
with open(self.extra_settings_filepath) as fd: