summaryrefslogtreecommitdiff
path: root/app/controllers/config_siemens_controller.rb
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2012-12-23 16:04:05 +0100
committerspag <spag@golwen.net>2012-12-23 16:04:05 +0100
commit55a0d5ce38f99226174f358279c02178eacd75d7 (patch)
tree8ad5fe87d51760bf8fa76bd60337c25ff16726f5 /app/controllers/config_siemens_controller.rb
parentf425280a6312638f364f6ae8d915a30d78a8dce4 (diff)
login/logout methods
Diffstat (limited to 'app/controllers/config_siemens_controller.rb')
-rw-r--r--app/controllers/config_siemens_controller.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/app/controllers/config_siemens_controller.rb b/app/controllers/config_siemens_controller.rb
index f398b1a..c09dfcf 100644
--- a/app/controllers/config_siemens_controller.rb
+++ b/app/controllers/config_siemens_controller.rb
@@ -80,6 +80,7 @@ class ConfigSiemensController < ApplicationController
@phone.mac_address = mac_address
@phone.hot_deskable = true
@phone.phone_model = PhoneModel.where('name LIKE ?', "#{phone_type}").first
+ @phone.tenant = tenant
if ! @phone.save
render(
:status => 500,
@@ -128,16 +129,13 @@ class ConfigSiemensController < ApplicationController
return
end
- phone_sip_account = PhoneSipAccount.new()
- phone_sip_account.phone_id = @phone.id
- phone_sip_account.sip_account_id = @sip_account.id
-
- if ! phone_sip_account.save
+ @phone.fallback_sip_account = @sip_account
+ if ! @phone.save
render(
:status => 500,
:layout => false,
:content_type => 'text/plain',
- :text => "<!-- #{phone_sip_account.errors.messages.inspect} -->",
+ :text => "<!-- #{@phone.errors.messages.inspect} -->",
)
return
end
@@ -152,13 +150,17 @@ class ConfigSiemensController < ApplicationController
@sip_account = @phone.sip_accounts.where(:sip_accountable_type => @phone.phoneable_type,
:sip_accountable_id => @phone.phoneable_id).first
+ if !@sip_account
+ @sip_account = @phone.fallback_sip_account
+ end
+
+ tenant = @phone.tenant
+
if @phone.phoneable
if @phone.phoneable_type == 'Tenant'
- tenant = @phone.phoneable
language = tenant.language.code
elsif @phone.phoneable_type == 'User'
language = @phone.phoneable.language.code
- tenant = @phone.phoneable.current_tenant
end
end