diff options
author | Peter Kozak <spag@golwen.net> | 2013-03-07 07:39:02 -0500 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-03-07 07:39:02 -0500 |
commit | 8be445e95ebe8c805dcfb1af0c02e3a3567aab18 (patch) | |
tree | faccfd30ff4a4d0b00e48a2a325066979ed59dda /app/models/sip_account.rb | |
parent | 678baf479066ad6b517b3a97925a7e37bf5327e4 (diff) | |
parent | 3e19646f46c772e10ed3d7a45e8c974ab23f625b (diff) |
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'app/models/sip_account.rb')
-rw-r--r-- | app/models/sip_account.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 3340a76..1ff3c9a 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -38,7 +38,8 @@ class SipAccount < ActiveRecord::Base has_many :ringtones, :as => :ringtoneable, :dependent => :destroy - has_many :calls, :finder_sql => lambda { |s| "SELECT DISTINCT calls_active.* FROM calls_active WHERE sip_account_id = #{self.id} OR b_sip_account_id = #{self.id}" } + has_many :call_legs, :class_name => 'Call' + has_many :b_call_legs, :class_name => 'Call', :foreign_key => 'b_sip_account_id' # Delegations: # @@ -83,6 +84,10 @@ class SipAccount < ActiveRecord::Base def to_s truncate((self.caller_name || "SipAccount ID #{self.id}"), :length => GsParameter.get('TO_S_MAX_CALLER_NAME_LENGTH')) + " (#{truncate(self.auth_name, :length => GsParameter.get('TO_S_MAX_LENGTH_OF_AUTH_NAME'))}@...#{self.host.split(/\./)[2,3].to_a.join('.') if self.host })" end + + def calls + self.call_legs + self.b_call_legs + end def call_forwarding_toggle( call_forwarding_service, to_voicemail = nil ) if ! self.phone_numbers.first |