From 82dc983f49778d17f4b9757fad88422618671520 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 23 May 2015 01:30:21 +0200 Subject: [PATCH] Added support for organization on auto wizard. --- contrib/auto_wizard_example.json | 5 +++++ lib/auto_wizard.rb | 37 ++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 9 deletions(-) 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|