@@ -86,17 +86,29 @@ def get_all_settings(self, organisation_id: str, plugin_id: str):
8686 return self .config_storage .get_all_settings (organisation_id , plugin_id )
8787
8888 def clone_settings_to_organisation (self , from_organisation : str , to_organisation : str ):
89- # One requirement is that only boefjes enabled in the from_organisation end up being enabled for the target.
89+ # One requirement is that only boefjes enabled in the from_organisation end up being enabled for the target,
90+ # and only normalizers disabled in the from_organisation end up being disabled.
9091 for plugin_id in self .config_storage .get_enabled_boefjes (to_organisation ):
9192 self .set_enabled_by_id (plugin_id , to_organisation , enabled = False )
9293
93- for plugin in self .get_all (from_organisation ):
94+ for plugin_id in self .config_storage .get_enabled_normalizers (to_organisation ):
95+ self .set_enabled_by_id (plugin_id , to_organisation , enabled = True )
96+
97+ # Clone all settings from the from_organisation to the to_organisation
98+ for plugin in self ._get_all_without_enabled ().values ():
99+ if not isinstance (plugin , Boefje ): # Only boefjes have settings
100+ continue
94101 if all_settings := self .get_all_settings (from_organisation , plugin .id ):
95102 self .upsert_settings (all_settings , to_organisation , plugin .id )
96103
104+ # Enable the same boefjes
97105 for plugin_id in self .config_storage .get_enabled_boefjes (from_organisation ):
98106 self .set_enabled_by_id (plugin_id , to_organisation , enabled = True )
99107
108+ # Disable the same normalizers
109+ for plugin_id in self .config_storage .get_disabled_normalizers (from_organisation ):
110+ self .set_enabled_by_id (plugin_id , to_organisation , enabled = False )
111+
100112 def upsert_settings (self , settings : dict , organisation_id : str , plugin_id : str ):
101113 self ._assert_settings_match_schema (settings , plugin_id , organisation_id )
102114 self ._put_boefje (plugin_id )
0 commit comments