summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2013-02-08 12:06:16 +0100
committerspag <spag@golwen.net>2013-02-08 12:06:16 +0100
commitaf5179a4a59bc21467448f292c752082dd8927b8 (patch)
treef023c302ceeb6aef88b2cf36b6f56042c9265f08 /app
parent901eb1ce8bdbfcd85678e06086cce5a0d7b50123 (diff)
set softkeyable
Diffstat (limited to 'app')
-rw-r--r--app/models/softkey.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/app/models/softkey.rb b/app/models/softkey.rb
index 3ae7e95..83c88ab 100644
--- a/app/models/softkey.rb
+++ b/app/models/softkey.rb
@@ -79,14 +79,18 @@ class Softkey < ActiveRecord::Base
# And make sure that there is no CallForward connected when not needed.
#
def clean_up_and_leave_only_values_which_make_sense_for_the_current_softkey_function_id
- if self.softkey_function_id != nil
- if ['blf','speed_dial','dtmf','conference'].include?(self.softkey_function.name)
- self.softkeyable_id = nil
- self.softkeyable_type = nil
- end
- if ['call_forwarding'].include?(self.softkey_function.name)
+ if self.softkey_function_id != nil
+ case self.softkey_function.name
+ when 'blf'
+ self.softkeyable = PhoneNumber.where(:number => self.number, :phone_numberable_type => 'SipAccount').first.try(:phone_numberable)
+ when 'conference'
+ self.softkeyable = PhoneNumber.where(:number => self.number, :phone_numberable_type => 'Conference').first.try(:phone_numberable)
+ when 'call_forwarding'
self.softkeyable = CallForward.where(:id => self.softkeyable_id).first
self.number = nil
+ else
+ self.softkeyable_id = nil
+ self.softkeyable_type = nil
end
end
end