From f93d42834e563fb217ba05e6d612bfc2ec9c856c Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Fri, 3 Jan 2020 16:56:48 +0100 Subject: [PATCH] scripts: populate warehouse_slug visualization parameter (#38596) --- debian/bijoe.docs | 1 + debian/scripts/warehouse_slug.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 debian/scripts/warehouse_slug.py diff --git a/debian/bijoe.docs b/debian/bijoe.docs index 0f44022..2c860e3 100644 --- a/debian/bijoe.docs +++ b/debian/bijoe.docs @@ -1,3 +1,4 @@ COPYING README.rst debian/nginx-example.conf +debian/scripts/warehouse_slug.py diff --git a/debian/scripts/warehouse_slug.py b/debian/scripts/warehouse_slug.py new file mode 100644 index 0000000..477c942 --- /dev/null +++ b/debian/scripts/warehouse_slug.py @@ -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