Added signature support to auto wizard.
This commit is contained in:
parent
26c1a6e211
commit
695d7a9ecc
2 changed files with 27 additions and 26 deletions
|
@ -35,6 +35,13 @@
|
||||||
"name": "Demo Organization"
|
"name": "Demo Organization"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"Signatures": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "default",
|
||||||
|
"body": "\n #{user.firstname} #{user.lastname}\n\n--\n Demo Organization\n--"
|
||||||
|
}
|
||||||
|
],
|
||||||
"Channels": [
|
"Channels": [
|
||||||
{
|
{
|
||||||
"area": "Email::Inbound",
|
"area": "Email::Inbound",
|
||||||
|
|
|
@ -92,39 +92,33 @@ returns
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# create EmailAddresses
|
# create EmailAddresses/Channels/Signatures
|
||||||
if auto_wizard_hash['EmailAddresses']
|
model_map = {
|
||||||
auto_wizard_hash['EmailAddresses'].each { |email_address_data|
|
'EmailAddresses' => 'EmailAddress',
|
||||||
|
'Channels' => 'Channel',
|
||||||
email_address_data_symbolized = email_address_data.symbolize_keys.merge(
|
'Signatures' => 'Signature',
|
||||||
|
}
|
||||||
|
model_map.each {|map_name, model|
|
||||||
|
next if !auto_wizard_hash[map_name]
|
||||||
|
auto_wizard_hash[map_name].each {|data|
|
||||||
|
data_symbolized = data.symbolize_keys.merge(
|
||||||
{
|
{
|
||||||
updated_by_id: admin_user.id,
|
updated_by_id: admin_user.id,
|
||||||
created_by_id: admin_user.id
|
created_by_id: admin_user.id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
EmailAddress.create_or_update(
|
if data_symbolized[:id] || data_symbolized[:name]
|
||||||
email_address_data_symbolized
|
Kernel.const_get(model).create_or_update(
|
||||||
)
|
data_symbolized
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Kernel.const_get(model).create(
|
||||||
|
data_symbolized
|
||||||
|
)
|
||||||
|
end
|
||||||
}
|
}
|
||||||
end
|
}
|
||||||
|
|
||||||
# create Channels
|
|
||||||
if auto_wizard_hash['Channels']
|
|
||||||
auto_wizard_hash['Channels'].each { |channel_data|
|
|
||||||
|
|
||||||
channel_data_symbolized = channel_data.symbolize_keys.merge(
|
|
||||||
{
|
|
||||||
updated_by_id: admin_user.id,
|
|
||||||
created_by_id: admin_user.id
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Channel.create(
|
|
||||||
channel_data_symbolized
|
|
||||||
)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# remove auto wizard file
|
# remove auto wizard file
|
||||||
FileUtils.rm auto_wizard_file_location
|
FileUtils.rm auto_wizard_file_location
|
||||||
|
|
Loading…
Reference in a new issue