03: do rename connector into tiles too

This commit is contained in:
Nicolas Roche 2022-01-26 11:04:50 +01:00
parent 39184f4e6f
commit f51e0b7fbd
1 changed files with 14 additions and 3 deletions

View File

@ -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)