2022-01-25 19:37:26 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# ex:
|
|
|
|
# $ ssh combo.node2.test.saas.entrouvert.org
|
2022-01-26 10:33:17 +01:00
|
|
|
# $ sudo -u combo combo-manage shell -d portail-braine-l-alleud.test.entrouvert.org < 03_combo_rename_title_connectors.py
|
2022-01-25 19:37:26 +01:00
|
|
|
|
|
|
|
import json
|
|
|
|
|
2022-01-26 11:04:50 +01:00
|
|
|
from combo.apps.dashboard.models import Tile
|
2022-01-25 19:37:26 +01:00
|
|
|
from combo.data.models import ConfigJsonCell, Page
|
|
|
|
|
2022-01-26 11:12:48 +01:00
|
|
|
page = Page.objects.get(title='Mon Compte')
|
2022-01-25 19:37:26 +01:00
|
|
|
cons = [
|
|
|
|
{'old': 'bla-dev', 'new': 'site-web'},
|
|
|
|
{'old': 'news-dev', 'new': 'actualites'},
|
|
|
|
{'old': 'events-dev', 'new': 'evenements'},
|
|
|
|
]
|
|
|
|
|
2022-01-26 11:04:50 +01:00
|
|
|
nb_updated_cells = 0
|
|
|
|
nb_updated_tiles = 0
|
2022-01-25 19:37:26 +01:00
|
|
|
|
|
|
|
for con in cons:
|
2022-01-26 11:04:50 +01:00
|
|
|
# cells
|
2022-01-25 19:37:26 +01:00
|
|
|
kwargs = {
|
|
|
|
'page': page,
|
|
|
|
'placeholder': 'content',
|
|
|
|
'parameters__connector': con['old'],
|
|
|
|
}
|
|
|
|
for cell in ConfigJsonCell.objects.filter(**kwargs):
|
|
|
|
cell.parameters['connector'] = con['new']
|
|
|
|
cell.save()
|
2022-01-26 11:04:50 +01:00
|
|
|
nb_updated_cells += 1
|
2022-01-25 19:37:26 +01:00
|
|
|
|
2022-01-26 11:04:50 +01:00
|
|
|
# tiles
|
|
|
|
for tile in Tile.objects.all():
|
2022-01-26 11:10:21 +01:00
|
|
|
if 'connector' in tile.cell.parameters and tile.cell.parameters['connector'] == con['old']:
|
2022-01-26 11:04:50 +01:00
|
|
|
tile.cell.parameters['connector'] = con['new']
|
2022-01-26 11:10:21 +01:00
|
|
|
tile.cell.save()
|
2022-01-26 11:04:50 +01:00
|
|
|
nb_updated_tiles += 1
|
2022-01-25 19:37:26 +01:00
|
|
|
|
2022-01-26 11:04:50 +01:00
|
|
|
|
|
|
|
print('%s cells updated on %s page' % (nb_updated_cells, page.get_online_url()))
|
|
|
|
print('%s tiles updated' % nb_updated_tiles)
|