File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
openwisp_controller/config/migrations Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 11from django .db import migrations
2- import json
2+ from django . db import migrations
33
44
55def change_owzt_to_global (apps , schema_editor ):
66 Template = apps .get_model ('config' , 'Template' )
7+ updated_templates = set ()
78 for template in Template .objects .filter (
8- type = 'vpn' , vpn__backend = 'openwisp_controller.vpn_backends.ZeroTier' ):
9- config = json . loads ( template . config )
10- if 'zerotier' in config :
11- for item in config .get ('zerotier' , []):
9+ type = 'vpn' , vpn__backend = 'openwisp_controller.vpn_backends.ZeroTier'
10+ ):
11+ if 'zerotier' in template . config :
12+ for item in template . config .get ('zerotier' , []):
1213 if item .get ('name' ) == 'ow_zt' :
1314 item ['name' ] = 'global'
15+ updated_templates .add (template )
16+ Template .objects .bulk_update (updated_templates , ['config' ])
1417
1518
1619class Migration (migrations .Migration ):
You can’t perform that action at this time.
0 commit comments