trabajo-afectivo/db/migrate/20181030000001_setting_add_placetel1.rb

78 lines
2.3 KiB
Ruby
Raw Normal View History

class SettingAddPlacetel1 < ActiveRecord::Migration[5.1]
2018-10-15 09:47:59 +00:00
def change
# return if it's a new setup
return if !Setting.exists?(name: 'system_init_done')
2018-10-15 09:47:59 +00:00
Setting.create_if_not_exists(
title: 'Placetel integration',
name: 'placetel_integration',
area: 'Integration::Switch',
2018-10-15 09:47:59 +00:00
description: 'Defines if Placetel (http://www.placetel.de) is enabled or not.',
options: {
2018-10-15 09:47:59 +00:00
form: [
{
display: '',
null: true,
name: 'placetel_integration',
tag: 'boolean',
2018-10-15 09:47:59 +00:00
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
2018-10-15 09:47:59 +00:00
preferences: {
prio: 1,
trigger: ['menu:render', 'cti:reload'],
2018-10-15 09:47:59 +00:00
authentication: true,
permission: ['admin.integration'],
2018-10-15 09:47:59 +00:00
},
frontend: true
2018-10-15 09:47:59 +00:00
)
placetel_config = Setting.find_by(name: 'placetel_config')
if !placetel_config
Setting.create!(
title: 'Placetel config',
name: 'placetel_config',
area: 'Integration::Placetel',
description: 'Defines the Placetel config.',
options: {},
state: { 'outbound' => { 'routing_table' => [], 'default_caller_id' => '' }, 'inbound' => { 'block_caller_ids' => [] } },
preferences: {
prio: 2,
permission: ['admin.integration'],
cache: ['placetelGetVoipUsers'],
},
frontend: false,
)
else
placetel_config.preferences[:cache] = ['placetelGetVoipUsers']
placetel_config.save!
end
2018-10-15 09:47:59 +00:00
Setting.create_if_not_exists(
title: 'PLACETEL Token',
name: 'placetel_token',
area: 'Integration::Placetel',
2018-10-15 09:47:59 +00:00
description: 'Token for placetel.',
options: {
2018-10-15 09:47:59 +00:00
form: [
{
display: '',
null: false,
name: 'placetel_token',
tag: 'input',
2018-10-15 09:47:59 +00:00
},
],
},
state: ENV['PLACETEL_TOKEN'] || SecureRandom.urlsafe_base64(20),
2018-10-15 09:47:59 +00:00
preferences: {
permission: ['admin.integration'],
},
frontend: false
2018-10-15 09:47:59 +00:00
)
end
end