From f51e0b7fbd570ebecc413faab6fba46ca1cf5ae4 Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Wed, 26 Jan 2022 11:04:50 +0100 Subject: [PATCH] 03: do rename connector into tiles too --- .../03_combo_rename_title_connectors.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/braine-l-alleud/03_combo_rename_title_connectors.py b/braine-l-alleud/03_combo_rename_title_connectors.py index 0e036d1..254f64c 100644 --- a/braine-l-alleud/03_combo_rename_title_connectors.py +++ b/braine-l-alleud/03_combo_rename_title_connectors.py @@ -5,6 +5,7 @@ import json +from combo.apps.dashboard.models import Tile from combo.data.models import ConfigJsonCell, Page page = Page.objects.get(title='Mon compte') @@ -14,9 +15,11 @@ cons = [ {'old': 'events-dev', 'new': 'evenements'}, ] -nb_updated = 0 +nb_updated_cells = 0 +nb_updated_tiles = 0 for con in cons: + # cells kwargs = { 'page': page, 'placeholder': 'content', @@ -25,7 +28,15 @@ for con in cons: for cell in ConfigJsonCell.objects.filter(**kwargs): cell.parameters['connector'] = con['new'] cell.save() - nb_updated += 1 + nb_updated_cells += 1 + + # tiles + for tile in Tile.objects.all(): + if tile.cell.parameters['connector'] == con['old']: + tile.cell.parameters['connector'] = con['new'] + tile.save() + nb_updated_tiles += 1 -print('%s cells updated on %s page' % (nb_updated, page.get_online_url())) +print('%s cells updated on %s page' % (nb_updated_cells, page.get_online_url())) +print('%s tiles updated' % nb_updated_tiles)