diff --git a/contrib/auto_wizard_example.json b/contrib/auto_wizard_example.json index 2f554c40e..d781cd3db 100644 --- a/contrib/auto_wizard_example.json +++ b/contrib/auto_wizard_example.json @@ -27,5 +27,10 @@ "realname": "Zammad Demo System", "email": "zammad_demo@localhost" } + ], + "Organization": [ + { + "name": "Demo Organization" + } ] } diff --git a/lib/auto_wizard.rb b/lib/auto_wizard.rb index c8bafe2c4..31d3e6a3f 100644 --- a/lib/auto_wizard.rb +++ b/lib/auto_wizard.rb @@ -31,6 +31,33 @@ returns admin_user = User.find( 1 ) + # set Settings + if auto_wizard_hash['Settings'] + auto_wizard_hash['Settings'].each { |setting_data| + Setting.set( setting_data['name'], setting_data['value'] ) + } + end + + # create Organizations + if auto_wizard_hash['Organizations'] + + auto_wizard_hash['Organizations'].each { |organization_data| + + organization_data_symbolized = organization_data.symbolize_keys + + organization_data_symbolized = organization_data_symbolized.merge( + { + updated_by_id: admin_user.id, + created_by_id: admin_user.id + } + ) + + Organization.create_if_not_exists( + organization_data_symbolized + ) + } + end + # create Users if auto_wizard_hash['Users'] @@ -62,15 +89,7 @@ returns } end - # set Settings - if auto_wizard_hash['Settings'] - - auto_wizard_hash['Settings'].each { |setting_data| - Setting.set( setting_data['name'], setting_data['value'] ) - } - end - - # add EmailAddresses + # create EmailAddresses if auto_wizard_hash['EmailAddresses'] auto_wizard_hash['EmailAddresses'].each { |email_address_data|