summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/call_forwards_controller.rb58
-rw-r--r--app/controllers/config_siemens_controller.rb4
-rw-r--r--app/models/ability.rb4
-rw-r--r--app/models/call_forward.rb123
-rw-r--r--app/models/hunt_group.rb2
-rw-r--r--app/models/phone_number.rb2
-rw-r--r--app/models/sip_account.rb8
-rw-r--r--app/models/softkey.rb6
-rw-r--r--app/views/call_forwards/_form.html.haml2
-rw-r--r--app/views/call_forwards/_index_core.html.haml14
-rw-r--r--app/views/call_forwards/index.html.haml2
-rw-r--r--app/views/call_forwards/show.html.haml24
-rw-r--r--app/views/gs_nodes/sync.xml.haml2
-rw-r--r--app/views/sip_accounts/_form_core.html.haml2
14 files changed, 102 insertions, 151 deletions
diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb
index b1ced87..cd72a38 100644
--- a/app/controllers/call_forwards_controller.rb
+++ b/app/controllers/call_forwards_controller.rb
@@ -1,7 +1,9 @@
class CallForwardsController < ApplicationController
- load_and_authorize_resource :phone_number
- load_and_authorize_resource :call_forward, :through => [:phone_number]
+ load_resource :phone_number
+ load_resource :sip_account
+ load_and_authorize_resource :call_forward, :through => [:phone_number, :sip_account]
+ before_filter :set_and_authorize_parent
before_filter :spread_breadcrumbs
class CallForwardingDestination
@@ -20,7 +22,7 @@ class CallForwardsController < ApplicationController
end
def new
- @call_forward = @phone_number.call_forwards.build
+ @call_forward = @parent.call_forwards.build
@call_forward.depth = GsParameter.get('DEFAULT_CALL_FORWARD_DEPTH')
@call_forward.active = true
@call_forwarding_destinations = call_forwarding_destination_types()
@@ -33,7 +35,7 @@ class CallForwardsController < ApplicationController
end
end
- if @phone_number.call_forwards.where(
+ if @parent.call_forwards.where(
:call_forward_case_id => CallForwardCase.find_by_value('noanswer').id,
:active => true
).count == 0
@@ -43,10 +45,11 @@ class CallForwardsController < ApplicationController
end
def create
- @call_forward = @phone_number.call_forwards.build( params[:call_forward] )
+ @call_forward = @parent.call_forwards.build( params[:call_forward] )
if @call_forward.save
- redirect_to phone_number_call_forward_path( @phone_number, @call_forward ), :notice => t('call_forwards.controller.successfuly_created')
+ m = method( :"#{@parent.class.name.underscore}_call_forward_path" )
+ redirect_to m.( @parent, @call_forward ), :notice => t('call_forwards.controller.successfuly_created')
else
@available_call_forward_cases = CallForwardCase.all
render :new
@@ -61,7 +64,8 @@ class CallForwardsController < ApplicationController
def update
@available_call_forward_cases = CallForwardCase.all
if @call_forward.update_attributes(params[:call_forward])
- redirect_to phone_number_call_forward_path( @phone_number, @call_forward ), :notice => t('call_forwards.controller.successfuly_updated')
+ m = method( :"#{@parent.class.name.underscore}_call_forward_path" )
+ redirect_to m.( @parent, @call_forward ), :notice => t('call_forwards.controller.successfuly_updated')
else
@call_forwarding_destinations = call_forwarding_destination_types()
render :edit
@@ -70,30 +74,46 @@ class CallForwardsController < ApplicationController
def destroy
@call_forward.destroy
- redirect_to phone_number_call_forwards_path( @phone_number ), :notice => t('call_forwards.controller.successfuly_destroyed')
+ redirect_to :root, :notice => t('call_forwards.controller.successfuly_destroyed')
end
private
+ private
+ def set_and_authorize_parent
+ @parent = @sip_account || @phone_number
+ authorize! :read, @parent
+ end
+
def spread_breadcrumbs
- if @phone_number && @phone_number.phone_numberable_type == 'SipAccount'
- @sip_account = @phone_number.phone_numberable
+ if @parent
+ if @parent.class == PhoneNumber && @parent.phone_numberable_type == 'SipAccount'
+ @sip_account = @parent.phone_numberable
+ end
if @sip_account.sip_accountable_type == 'User'
- @user = @phone_number.phone_numberable.sip_accountable
- add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
- add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user)
- add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user)
- add_breadcrumb @sip_account, user_sip_account_path(@user, @sip_account)
+ @user = @sip_account.sip_accountable
+ if @parent.class == PhoneNumber
+ add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
+ add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user)
+ add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user)
+ add_breadcrumb @sip_account, user_sip_account_path(@user, @sip_account)
+ add_breadcrumb t("phone_numbers.index.page_title"), sip_account_phone_numbers_path(@sip_account)
+ add_breadcrumb @parent, sip_account_phone_number_path(@sip_account, @parent)
+ elsif @parent.class == SipAccount
+ add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
+ add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user)
+ add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user)
+ end
end
if @sip_account.sip_accountable_type == 'Tenant'
@tenant = @sip_account.sip_accountable
add_breadcrumb t("sip_accounts.index.page_title"), tenant_sip_accounts_path(@tenant)
add_breadcrumb @sip_account, tenant_sip_account_path(@tenant, @sip_account)
end
- add_breadcrumb t("phone_numbers.index.page_title"), sip_account_phone_numbers_path(@sip_account)
- add_breadcrumb @phone_number, sip_account_phone_number_path(@sip_account, @phone_number)
- add_breadcrumb t("call_forwards.index.page_title"), phone_number_call_forwards_path(@phone_number)
+
+ add_breadcrumb t("call_forwards.index.page_title"), phone_number_call_forwards_path(@parent)
if @call_forward && !@call_forward.new_record?
- add_breadcrumb @call_forward, phone_number_call_forward_path(@phone_number, @call_forward)
+ m = method( :"#{@parent.class.name.underscore}_call_forward_path" )
+ add_breadcrumb @call_forward, m.(@parent, @call_forward)
end
end
end
diff --git a/app/controllers/config_siemens_controller.rb b/app/controllers/config_siemens_controller.rb
index bbeba46..1966d49 100644
--- a/app/controllers/config_siemens_controller.rb
+++ b/app/controllers/config_siemens_controller.rb
@@ -1068,8 +1068,8 @@ class ConfigSiemensController < ApplicationController
phone_numbers.push(phone_number.number)
assistant_call_forwardings = phone_number.call_forwards.where(:call_forward_case_id => CallForwardCase.where(:value => 'assistant').first.id)
assistant_call_forwardings.each do |assistant_call_forwarding|
- if assistant_call_forwarding.call_forwardable_type == 'HuntGroup' && assistant_call_forwarding.call_forwardable_id.to_i > 0
- hunt_groups.push(assistant_call_forwarding.call_forwardable_id.to_i)
+ if assistant_call_forwarding.destinationable_type == 'HuntGroup' && assistant_call_forwarding.destinationable_id.to_i > 0
+ hunt_groups.push(assistant_call_forwarding.destinationable_id.to_i)
end
end
end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index d66577d..d886d53 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -129,7 +129,7 @@ class Ability
can :read, SipAccount, :sip_accountable_type => 'User', :sip_accountable_id => user.id
user.sip_accounts.each do |sip_account|
can :read, PhoneNumber, :id => sip_account.phone_number_ids
- can :manage, CallForward, :phone_number_id => sip_account.phone_number_ids
+ can :manage, CallForward, :call_forwardable_id => sip_account.phone_number_ids
can :manage, Ringtone, :ringtoneable_type => 'PhoneNumber', :ringtoneable_id => sip_account.phone_number_ids
can [:read, :destroy, :call] , CallHistory, :id => sip_account.call_history_ids
end
@@ -158,7 +158,7 @@ class Ability
# User can manage CallForwards of the PhoneNumbers of his
# own SipAccounts:
#
- can :manage, CallForward, :phone_number_id => user.phone_number_ids
+ can :manage, CallForward, :call_forwardable_id => user.phone_number_ids
# SoftkeyFunctions
#
diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb
index 088bd23..b304439 100644
--- a/app/models/call_forward.rb
+++ b/app/models/call_forward.rb
@@ -6,17 +6,17 @@ class CallForward < ActiveRecord::Base
:destination, :source, :depth, :active, :to_voicemail,
:hunt_group_id,
:call_forwardable_type, :call_forwardable_id,
- :call_forwarding_destination, :position, :uuid
+ :call_forwarding_destination, :position, :uuid,
+ :destinationable_type, :destinationable_id
- belongs_to :phone_number
belongs_to :call_forwardable, :polymorphic => true
+ belongs_to :destinationable, :polymorphic => true
has_many :softkeys, :as => :softkeyable
- acts_as_list :scope => [ :phone_number_id, :call_forward_case_id ]
+ acts_as_list :scope => [ :call_forwardable_id, :call_forwardable_type, :call_forward_case_id ]
- validates_presence_of :phone_number
validates_presence_of :call_forward_case_id
- validates_presence_of :destination, :if => Proc.new { |cf| cf.call_forwardable_type.to_s.downcase == 'phonenumber' || cf.call_forwardable_type.blank? }
+ validates_presence_of :destination, :if => Proc.new { |cf| cf.destinationable_type.to_s.downcase == 'phonenumber' || cf.destinationable_type.blank? }
validates_inclusion_of :destination,
:in => [ nil, '' ],
@@ -44,23 +44,20 @@ class CallForward < ActiveRecord::Base
:in => [ nil ],
:if => Proc.new { |cf| cf.call_forward_case_id != 3 }
- validate :validate_empty_hunt_group, :if => Proc.new { |cf| cf.active == true && cf.call_forwardable_type == 'HuntGroup' && cf.call_forward_case.value == 'assistant' }
+ validate :validate_empty_hunt_group, :if => Proc.new { |cf| cf.active == true && cf.destinationable_type == 'HuntGroup' && cf.call_forward_case.value == 'assistant' }
validates_presence_of :uuid
validates_uniqueness_of :uuid
# Make sure the call forward's parent can't be changed:
before_validation { |cfwd|
- if cfwd.id \
- && cfwd.phone_number_id != cfwd.phone_number_id_was
- errors.add( :phone_number_id, "cannot be changed." )
+ if cfwd.id && (cfwd.call_forwardable_id != cfwd.call_forwardable_id_was || cfwd.call_forwardable_type != cfwd.call_forwardable_type_was)
+ errors.add( :call_forwardable_id, "cannot be changed." )
end
}
- #before_validation :set_call_forwardable
before_save :split_and_format_destination_numbers
after_save :set_presence
- after_save :work_through_callforward_rules_act_per_sip_account
after_save :deactivate_concurring_entries, :if => Proc.new { |cf| cf.active == true }
before_destroy :check_if_other_callforward_rules_have_to_be_destroyed
before_destroy :deactivate_connected_softkeys
@@ -70,70 +67,25 @@ class CallForward < ActiveRecord::Base
end
def to_s
- if self.call_forwardable_type.blank?
- self.call_forwardable_type = ''
+ if self.destinationable_type.blank?
+ self.destinationable_type = ''
else
- call_forwardable_type = " #{self.call_forwardable_type}"
+ destinationable_type = " #{self.destinationable_type}"
end
- if self.call_forwardable
- destination = "#{self.call_forwardable}#{call_forwardable_type}"
+ if self.destinationable
+ destination = "#{self.destinationable}#{destinationable_type}"
else
- destination = "#{self.destination}#{call_forwardable_type}"
+ destination = "#{self.destination}#{destinationable_type}"
end
- "#{self.phone_number} (#{I18n.t("call_forward_cases.#{self.call_forward_case}")}) -> #{destination}"
- end
-
- def set_this_callforward_rule_to_all_phone_numbers_of_the_parent_sip_account
- # This is to make sure that no recursion kicks in.
- #
- if ! self.phone_number.phone_numberable.respond_to? :callforward_rules_act_per_sip_account
- return false
- end
-
- old_value_of_callforward_rules_act_per_sip_account = self.phone_number.phone_numberable.callforward_rules_act_per_sip_account
- self.phone_number.phone_numberable.update_attributes({:callforward_rules_act_per_sip_account => false})
-
- attributes_of_this_call_forward = self.attributes.delete_if {|key, value| ['id','updated_at','created_at','phone_number_id','call_forward_case_id', 'uuid'].include?(key)}
- phone_numbers = self.phone_number.phone_numberable.phone_numbers.where('id != ?', self.phone_number.id)
-
- phone_numbers.each do |phone_number|
- # Problem
- call_forward = phone_number.call_forwards.find_or_create_by_call_forward_case_id_and_position(self.call_forward_case_id, self.position, attributes_of_this_call_forward)
- call_forward.update_attributes(attributes_of_this_call_forward)
- end
-
- self.phone_number.phone_numberable.update_attributes({:callforward_rules_act_per_sip_account => old_value_of_callforward_rules_act_per_sip_account})
- end
-
- def destroy_all_similar_callforward_rules_of_the_parent_sip_account
- # This is to make sure that no recursion kicks in.
- #
- if ! self.phone_number.phone_numberable.respond_to? :callforward_rules_act_per_sip_account
- return false
- end
-
- old_value_of_callforward_rules_act_per_sip_account = self.phone_number.phone_numberable.callforward_rules_act_per_sip_account
- self.phone_number.phone_numberable.update_attributes({:callforward_rules_act_per_sip_account => false})
-
- phone_numbers_of_parent_sip_account = self.phone_number.phone_numberable.phone_numbers.where('id != ?', self.phone_number.id)
-
- phone_numbers_of_parent_sip_account.each do |phone_number|
- if self.call_forwardable_type != 'Voicemail'
- phone_number.call_forwards.where(:call_forward_case_id => self.call_forward_case_id, :destination => self.destination).destroy_all
- else
- phone_number.call_forwards.where(:call_forward_case_id => self.call_forward_case_id, :call_forwardable_type => self.call_forwardable_type).destroy_all
- end
- end
-
- self.phone_number.phone_numberable.update_attributes({:callforward_rules_act_per_sip_account => old_value_of_callforward_rules_act_per_sip_account})
+ "#{self.call_forwardable} (#{I18n.t("call_forward_cases.#{self.call_forward_case}")}) -> #{destination}"
end
def call_forwarding_destination
- "#{self.call_forwardable_id}:#{self.call_forwardable_type}"
+ "#{self.destinationable_id}:#{self.destinationable_type}"
end
def call_forwarding_destination=(destination_record)
- self.call_forwardable_id, delimeter, self.call_forwardable_type = destination_record.to_s.partition(':')
+ self.destinationable_id, delimeter, self.destinationable_type = destination_record.to_s.partition(':')
end
def toggle
@@ -168,7 +120,7 @@ class CallForward < ActiveRecord::Base
state = 'terminated'
if self.active
- if self.call_forwardable_type and self.call_forwardable_type.downcase() == 'voicemail'
+ if self.destinationable_type and self.destinationable_type.downcase() == 'voicemail'
state = 'early'
else
state = 'confirmed'
@@ -187,47 +139,28 @@ class CallForward < ActiveRecord::Base
#return send_presence_event(self.call_forward_case.value, state)
end
- def set_call_forwardable
+ def set_destinationable
if @hunt_group_id && HuntGroup.where(:id => @hunt_group_id.to_i).count > 0
- self.call_forwardable = HuntGroup.where(:id => @hunt_group_id.to_i).first
+ self.destinationable = HuntGroup.where(:id => @hunt_group_id.to_i).first
end
if @to_voicemail && @to_voicemail.first.downcase == 'true'
- self.call_forwardable_type = 'Voicemail'
- self.call_forwardable_id = nil
+ self.destinationable_type = 'Voicemail'
+ self.destinationable_id = nil
end
end
- def work_through_callforward_rules_act_per_sip_account
- if ! self.phone_number.phone_numberable.respond_to? :callforward_rules_act_per_sip_account
- return false
- end
-
- if self.phone_number.phone_numberable.callforward_rules_act_per_sip_account == true
- self.set_this_callforward_rule_to_all_phone_numbers_of_the_parent_sip_account
- end
- end
-
- def check_if_other_callforward_rules_have_to_be_destroyed
- if ! self.phone_number.phone_numberable.respond_to? :callforward_rules_act_per_sip_account
- return false
- end
-
- if self.phone_number.phone_numberable.callforward_rules_act_per_sip_account == true
- self.destroy_all_similar_callforward_rules_of_the_parent_sip_account
- end
- end
def send_presence_event(state, call_forwarding_service = nil)
dialplan_function = "cftg-#{self.id}"
unique_id = "call_forwarding_#{self.id}"
if call_forwarding_service == 'always'
- dialplan_function = "cfutg-#{self.phone_number.id}"
- unique_id = "call_forwarding_number_#{self.phone_number.id}"
+ dialplan_function = "cfutg-#{self.call_forwardable.id}"
+ unique_id = "call_forwarding_number_#{self.call_forwardable.id}"
elsif call_forwarding_service == 'assistant'
- dialplan_function = "cfatg-#{self.phone_number.id}"
- unique_id = "call_forwarding_number_#{self.phone_number.id}"
+ dialplan_function = "cfatg-#{self.call_forwardable.id}"
+ unique_id = "call_forwarding_number_#{self.call_forwardable.id}"
end
if dialplan_function
@@ -245,7 +178,7 @@ class CallForward < ActiveRecord::Base
end
def deactivate_concurring_entries
- CallForward.where(:phone_number_id => self.phone_number_id, :call_forward_case_id => self.call_forward_case_id, :active => true).each do |call_forwarding_entry|
+ CallForward.where(:call_forwardable_id => self.call_forwardable_id, :call_forwardable_type => self.call_forwardable_type, :call_forward_case_id => self.call_forward_case_id, :active => true).each do |call_forwarding_entry|
if call_forwarding_entry.id != self.id
call_forwarding_entry.update_attributes(:active => false)
end
@@ -253,7 +186,7 @@ class CallForward < ActiveRecord::Base
end
def validate_empty_hunt_group
- hunt_group = self.call_forwardable
+ hunt_group = self.destinationable
if hunt_group && hunt_group.hunt_group_members.where(:active => true).count == 0
errors.add(:call_forwarding_destination, 'HuntGroup has no active members')
end
diff --git a/app/models/hunt_group.rb b/app/models/hunt_group.rb
index 5011bf0..7338606 100644
--- a/app/models/hunt_group.rb
+++ b/app/models/hunt_group.rb
@@ -2,7 +2,7 @@ class HuntGroup < ActiveRecord::Base
attr_accessible :name, :strategy, :seconds_between_jumps, :phone_numbers_attributes
belongs_to :tenant, :touch => true
- has_many :call_forwards, :as => :call_forwardable, :dependent => :destroy
+ has_many :call_forwards, :as => :destinationable, :dependent => :destroy
validates_uniqueness_of :name, :scope => :tenant_id,
:allow_nil => true, :allow_blank => true
diff --git a/app/models/phone_number.rb b/app/models/phone_number.rb
index d1e950f..f6453ce 100644
--- a/app/models/phone_number.rb
+++ b/app/models/phone_number.rb
@@ -3,7 +3,7 @@ class PhoneNumber < ActiveRecord::Base
attr_accessible :name, :number, :gs_node_id, :access_authorization_user_id
- has_many :call_forwards, :dependent => :destroy
+ has_many :call_forwards, :as => :call_forwardable, :dependent => :destroy
has_many :ringtones, :as => :ringtoneable, :dependent => :destroy
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb
index 420e395..a39982b 100644
--- a/app/models/sip_account.rb
+++ b/app/models/sip_account.rb
@@ -16,7 +16,7 @@ class SipAccount < ActiveRecord::Base
has_many :phones, :through => :phone_sip_accounts
has_many :phone_numbers, :as => :phone_numberable, :dependent => :destroy
- has_many :call_forwards, :through => :phone_numbers
+ has_many :call_forwards, :as => :call_forwardable, :dependent => :destroy
belongs_to :tenant
belongs_to :sip_domain
@@ -96,8 +96,8 @@ class SipAccount < ActiveRecord::Base
if call_forwarding_master.active
call_forwarding_master.active = false
else
- if call_forwarding_service = 'assistant' && call_forwarding_master.call_forwardable_type == 'HuntGroup' && call_forwarding_master.call_forwardable
- if call_forwarding_master.call_forwardable.hunt_group_members.where(:active => true).count > 0
+ if call_forwarding_service = 'assistant' && call_forwarding_master.destinationable_type == 'HuntGroup' && call_forwarding_master.destinationable
+ if call_forwarding_master.destinationable.hunt_group_members.where(:active => true).count > 0
call_forwarding_master.active = true
else
call_forwarding_master.active = false
@@ -109,7 +109,7 @@ class SipAccount < ActiveRecord::Base
call_forwarding = phone_number.call_forwards.where(:call_forward_case_id => service_id).order(:active).all(:conditions => 'source IS NULL OR source = ""').first
if ! call_forwarding
call_forwarding = CallForward.new()
- call_forwarding.phone_number_id = phone_number.id
+ call_forwarding.call_forwardable = phone_number
end
if to_voicemail == nil
diff --git a/app/models/softkey.rb b/app/models/softkey.rb
index 4b758e0..8049456 100644
--- a/app/models/softkey.rb
+++ b/app/models/softkey.rb
@@ -30,7 +30,7 @@ class Softkey < ActiveRecord::Base
# We pick one phone_number and display the rules of it.
#
phone_number = self.sip_account.phone_numbers.order(:number).first
- call_forwards = self.sip_account.call_forwards.where(:phone_number_id => phone_number.id)
+ call_forwards = self.sip_account.call_forwards.where(:call_forwardable_id => phone_number.id, :call_forwardable_type => 'PhoneNumber')
else
call_forwards = self.sip_account.call_forwards
end
@@ -42,8 +42,8 @@ class Softkey < ActiveRecord::Base
map{ |phone_number| phone_number.phone_numberable.hunt_group.id }.
uniq
- call_forwards + CallForward.where(:call_forwardable_type => 'HuntGroup', :call_forwardable_id => hunt_group_ids).
- where('phone_number_id NOT IN (?)', phone_numbers_ids)
+ call_forwards + CallForward.where(:destinationable_type => 'HuntGroup', :destinationable_id => hunt_group_ids, :call_forwardable_type => 'PhoneNumber').
+ where('call_forwardable_id NOT IN (?)', phone_numbers_ids)
end
end
diff --git a/app/views/call_forwards/_form.html.haml b/app/views/call_forwards/_form.html.haml
index 58ffd78..1944fc4 100644
--- a/app/views/call_forwards/_form.html.haml
+++ b/app/views/call_forwards/_form.html.haml
@@ -1,4 +1,4 @@
-= simple_form_for([ @phone_number, @call_forward ]) do |f|
+= simple_form_for([ @parent, @call_forward ]) do |f|
= f.error_notification
= render "form_core", :f => f
diff --git a/app/views/call_forwards/_index_core.html.haml b/app/views/call_forwards/_index_core.html.haml
index 878e0e2..48afa54 100644
--- a/app/views/call_forwards/_index_core.html.haml
+++ b/app/views/call_forwards/_index_core.html.haml
@@ -2,7 +2,7 @@
%thead
%tr
- if !@phone_number
- %th= t('call_forwards.index.phone_number_id')
+ %th= t('call_forwards.index.call_forwardable')
%th= t('call_forwards.index.call_forward_case_id')
%th= t('call_forwards.index.timeout')
%th= t('call_forwards.index.destination')
@@ -15,18 +15,18 @@
- for call_forward in call_forwards
%tr
- if !@phone_number
- %td= call_forward.phone_number
+ %td= call_forward.call_forwardable
%td= t("call_forward_cases.#{call_forward.call_forward_case.value}")
%td= call_forward.timeout
%td
= call_forward.destination
- - if call_forward.call_forwardable_type
+ - if call_forward.destinationable_type
%br
- = call_forward.call_forwardable_type
- - if call_forward.call_forwardable
- = ": #{call_forward.call_forwardable}"
+ = call_forward.destinationable_type
+ - if call_forward.destinationable_id
+ = ": #{call_forward.destinationable}"
%td= call_forward.source
- if GuiFunction.display?('depth_field_value_in_index_table', current_user)
%td= call_forward.depth
%td= call_forward.active
- =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => call_forward.phone_number, :child => call_forward} \ No newline at end of file
+ =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => call_forward.call_forwardable, :child => call_forward} \ No newline at end of file
diff --git a/app/views/call_forwards/index.html.haml b/app/views/call_forwards/index.html.haml
index 91b923a..e206653 100644
--- a/app/views/call_forwards/index.html.haml
+++ b/app/views/call_forwards/index.html.haml
@@ -3,4 +3,4 @@
- if @call_forwards.count > 0
= render "index_core", :call_forwards => @call_forwards
-= render :partial => 'shared/create_link', :locals => {:parent => @phone_number, :child_class => CallForward} \ No newline at end of file
+= render :partial => 'shared/create_link', :locals => {:parent => @parent, :child_class => CallForward} \ No newline at end of file
diff --git a/app/views/call_forwards/show.html.haml b/app/views/call_forwards/show.html.haml
index c2187b1..9f9d27a 100644
--- a/app/views/call_forwards/show.html.haml
+++ b/app/views/call_forwards/show.html.haml
@@ -1,25 +1,23 @@
- content_for :title, t("call_forwards.show.page_title")
%p
- %strong= t('call_forwards.show.phone_number_id') + ":"
- = @call_forward.phone_number
+ %strong= t('call_forwards.show.call_forwardable') + ":"
+ = "#{@call_forward.call_forwardable_type}: #{@call_forward.call_forwardable}"
%p
- %strong= t('call_forwards.show.call_forward_case_id') + ":"
+ %strong= t('call_forwards.show.call_forward_case') + ":"
= t("call_forward_cases.#{@call_forward.call_forward_case.value}")
%p
%strong= t('call_forwards.show.timeout') + ":"
= @call_forward.timeout
%p
%strong= t('call_forwards.show.destination') + ":"
- = @call_forward.destination
-- if @call_forward.call_forwardable_type == 'HuntGroup' && @call_forward.call_forwardable.class == HuntGroup
- %p
- %strong= t('call_forwards.show.hunt_group') + ":"
- = @call_forward.call_forwardable
-- if @call_forward.call_forwardable_type == 'Voicemail'
- %p
- %strong= t('call_forwards.show.to_voicemail') + ":"
- = 'active'
+ - if @call_forward.destinationable_id && @call_forward.destinationable
+ = "#{@call_forward.destinationable_type}: #{@call_forward.destinationable}"
+ - elsif !@call_forward.destinationable_type.blank?
+ = "#{@call_forward.destinationable_type}: #{@call_forward.destination}"
+ - else
+ = @call_forward.destination
+
%p
%strong= t('call_forwards.show.source') + ":"
= @call_forward.source
@@ -30,4 +28,4 @@
%strong= t('call_forwards.show.active') + ":"
= @call_forward.active
-= render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @phone_number, :child => @call_forward } \ No newline at end of file
+= render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @parent, :child => @call_forward } \ No newline at end of file
diff --git a/app/views/gs_nodes/sync.xml.haml b/app/views/gs_nodes/sync.xml.haml
index a2fa71a..bba5c4e 100644
--- a/app/views/gs_nodes/sync.xml.haml
+++ b/app/views/gs_nodes/sync.xml.haml
@@ -55,7 +55,7 @@
- if !@call_forwards.blank?
%call_forwards
- @call_forwards.each do |call_forward|
- %call_forward{ :uuid => call_forward.uuid, :service => call_forward.call_forward_case.try(:value), :timeout => call_forward.timeout, :destination => call_forward.destination, :source => call_forward.source, :active => call_forward.active.to_s, :created_at => call_forward.created_at, :updated_at => call_forward.updated_at, :phone_number_uuid => call_forward.phone_number.try(:uuid), :depth => call_forward.depth, :call_forwardable_type => call_forward.call_forwardable_type, :call_forwardable_uuid => call_forward.call_forwardable.try(:uuid), :position => call_forward.position}
+ %call_forward{ :uuid => call_forward.uuid, :service => call_forward.call_forward_case.try(:value), :timeout => call_forward.timeout, :destination => call_forward.destination, :source => call_forward.source, :active => call_forward.active.to_s, :created_at => call_forward.created_at, :updated_at => call_forward.updated_at, :phone_number_uuid => call_forward.phone_number.try(:uuid), :depth => call_forward.depth, :call_forwardable_type => call_forward.call_forwardable_type, :call_forwardable_uuid => call_forward.call_forwardable.try(:uuid), :destinationable_type => call_forward.destinationable_type, :destinationable_uuid => call_forward.destinationable.try(:uuid), :position => call_forward.position}
- if !@softkeys.blank?
%softkeys
diff --git a/app/views/sip_accounts/_form_core.html.haml b/app/views/sip_accounts/_form_core.html.haml
index 1a8876a..1a09912 100644
--- a/app/views/sip_accounts/_form_core.html.haml
+++ b/app/views/sip_accounts/_form_core.html.haml
@@ -13,6 +13,6 @@
- if @sip_account.sip_accountable_type == 'User'
= f.input :hotdeskable, :label => t('sip_accounts.form.hotdeskable.label'), :hint => conditional_hint('sip_accounts.form.hotdeskable.hint')
= f.input :clip_no_screening, :label => t('sip_accounts.form.clip_no_screening.label'), :hint => conditional_hint('sip_accounts.form.clip_no_screening.hint')
- - if CallForward.where(:phone_number_id => @sip_account.phone_number_ids).count == 0 || @sip_account.callforward_rules_act_per_sip_account == true
+ - if CallForward.where(:call_forwardable_id => @sip_account.phone_number_ids, :call_forwardable_type => 'PhoneNumber').count == 0 || @sip_account.callforward_rules_act_per_sip_account == true
= f.input :callforward_rules_act_per_sip_account, :label => t('sip_accounts.form.callforward_rules_act_per_sip_account.label'), :hint => conditional_hint('sip_accounts.form.callforward_rules_act_per_sip_account.hint')
= f.input :language_code, :collection => Language.all.collect{|l| [l.to_s, l.code]}, :label => t('sip_accounts.form.language_code.label'), :hint => conditional_hint('sip_accounts.form.language_id.hint'), :include_blank => false