scripts: populate warehouse_slug visualization parameter (#38596)

This commit is contained in:
Valentin Deniaud 2020-01-03 16:56:48 +01:00
parent ebb9cb3e39
commit f93d42834e
2 changed files with 21 additions and 0 deletions

1
debian/bijoe.docs vendored
View File

@ -1,3 +1,4 @@
COPYING
README.rst
debian/nginx-example.conf
debian/scripts/warehouse_slug.py

20
debian/scripts/warehouse_slug.py vendored Normal file
View File

@ -0,0 +1,20 @@
"""
In order to allow for import/export between instances, warehouses are now
retrieved by slug and not by name.
This new information is available in the model files, but for existing
visualizations it should be manually added, using this script.
For a standard multitenants install, it can be ran using the command :
sudo -u bijoe bijoe-manage tenant_command runscript --all-tenants /usr/share/doc/bijoe/warehouse_slug.py
"""
from bijoe.utils import get_warehouses
from bijoe.visualization.models import Visualization
warehouses = get_warehouses()
for visu in Visualization.objects.all():
for warehouse in warehouses:
if warehouse.name == visu.parameters['warehouse']:
visu.parameters['warehouse_slug'] = warehouse.slug
visu.save()
break