From 846c6ca704e587621eab0c373693c4f52e4c8433 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 7 Mar 2013 11:25:33 +0100 Subject: Added a different VIEW definition for sqlite3 and refactored some has_many code for the sip_account. --- app/models/sip_account.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 81b9c1c..cdb609d 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 -- cgit v1.2.3 From 3e19646f46c772e10ed3d7a45e8c974ab23f625b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 7 Mar 2013 11:34:22 +0100 Subject: Added belongs_to :call_route, :touch => true #223 --- app/models/route_element.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/route_element.rb b/app/models/route_element.rb index 94f0f84..7d37db0 100644 --- a/app/models/route_element.rb +++ b/app/models/route_element.rb @@ -3,7 +3,7 @@ class RouteElement < ActiveRecord::Base attr_accessible :call_route_id, :var_in, :var_out, :pattern, :replacement, :action, :mandatory, :position - belongs_to :call_route + belongs_to :call_route, :touch => true acts_as_list :scope => :call_route -- cgit v1.2.3