Projet

Général

Profil

0004-scripts-populate-warehouse_slug-visualization-parame.patch

Valentin Deniaud, 15 janvier 2020 15:33

Télécharger (1,64 ko)

Voir les différences:

Subject: [PATCH 4/4] 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
debian/bijoe.docs
1 1
COPYING
2 2
README.rst
3 3
debian/nginx-example.conf
4
debian/scripts/warehouse_slug.py
debian/scripts/warehouse_slug.py
1
"""
2
In order to allow for import/export between instances, warehouses are now
3
retrieved by slug and not by name.
4
This new information is available in the model files, but for existing
5
visualizations it should be manually added, using this script.
6
For a standard multitenants install, it can be ran using the command :
7
sudo -u bijoe bijoe-manage tenant_command runscript --all-tenants /usr/share/doc/bijoe/warehouse_slug.py
8
"""
9

  
10
from bijoe.utils import get_warehouses
11
from bijoe.visualization.models import Visualization
12

  
13

  
14
warehouses = get_warehouses()
15
for visu in Visualization.objects.all():
16
    for warehouse in warehouses:
17
        if warehouse.name == visu.parameters['warehouse']:
18
            visu.parameters['warehouse_slug'] = warehouse.slug
19
            visu.save()
20
            break
0
-