diff options
author | Peter Kozak <spag@golwen.net> | 2013-04-02 12:17:32 +0200 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-04-02 12:17:32 +0200 |
commit | deae02d7ae971da152da39193c89ee2b85d6207e (patch) | |
tree | 4bba2b453d97db55b2d00351bf3c4c5ec41dc045 | |
parent | 68ee69efeca95e6fa5fb063ca77274cffb053692 (diff) |
create voicemail_accounts
-rw-r--r-- | lib/tasks/csv_user_import.rake | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/tasks/csv_user_import.rake b/lib/tasks/csv_user_import.rake index 81959d5..e65bc1f 100644 --- a/lib/tasks/csv_user_import.rake +++ b/lib/tasks/csv_user_import.rake @@ -129,6 +129,16 @@ namespace :user_import do end if user + # Create voicemail account + voicemail_account = user.voicemail_accounts.first + if !voicemail_account + if VoicemailAccount.where(:name => "user_#{user.user_name}").count == 0 + voicemail_account = user.voicemail_accounts.create(:name => "user_#{user.user_name}", :active => true ) + else + voicemail_account = user.voicemail_accounts.create(:active => true) + end + end + # Find or create a sip_accounts ['VoipNr1', 'VoipNr2', 'VoipNr3'].each_with_index do |phone_number_type, index| @@ -141,6 +151,9 @@ namespace :user_import do if !phone_number_type.blank? && !csv_user[phone_number_type].blank? sip_account = user.sip_accounts.where(:auth_name => auth_name).first if sip_account + if sip_account.voicemail_account != voicemail_account + sip_account.update_attributes(:voicemail_account_id => voicemail_account.id) + end if sip_account.caller_name.to_s != user.to_s sip_account.update_attributes(:caller_name => user.to_s) end @@ -154,6 +167,7 @@ namespace :user_import do :hotdeskable => true, :callforward_rules_act_per_sip_account => true, :gs_node_id => gs_node_id, + :voicemail_account_id => voicemail_account.id, ) end |