diff --git a/api/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb b/api/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb index 2d45ead3d..5997a095f 100644 --- a/api/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb +++ b/api/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb @@ -50,6 +50,7 @@ def create # OPTIMIZE: move this into a delayed job? update_app_list + update_sub_tenants @organization_active_apps = @organization.app_instances @@ -141,5 +142,19 @@ def update_app_list existing_apps.reload end end + + def update_sub_tenants + return unless params[:organization].key?(:sub_tenant_ids) + + sub_tenants = MnoEnterprise::SubTenant.where({'id.in' => params[:organization][:sub_tenant_ids]}) + + sub_tenants.to_a.each do |sub_tnt| + new_client_ids = sub_tnt.client_ids + new_client_ids << @organization.id + new_client_ids = new_client_ids.collect(&:to_s) + + sub_tnt.update({"client_ids"=>new_client_ids}) + end + end end end