diff options
Diffstat (limited to 'app/models/call_forward.rb')
-rw-r--r-- | app/models/call_forward.rb | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index a4bfbb5..874a0de 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -7,7 +7,8 @@ class CallForward < ActiveRecord::Base :hunt_group_id, :call_forwardable_type, :call_forwardable_id, :call_forwarding_destination, :position, :uuid, - :destinationable_type, :destinationable_id + :destinationable_type, :destinationable_id, + :destination_phone_number, :destination_greeting belongs_to :call_forwardable, :polymorphic => true belongs_to :destinationable, :polymorphic => true @@ -23,12 +24,6 @@ class CallForward < ActiveRecord::Base :if => Proc.new { |cf| cf.to_voicemail == true } belongs_to :call_forward_case - - validates_numericality_of :depth, - :allow_nil => true, - :only_integer => true, - :greater_than_or_equal_to => 1, - :less_than_or_equal_to => (GsParameter.get('MAX_CALL_FORWARD_DEPTH').nil? ? 0 : GsParameter.get('MAX_CALL_FORWARD_DEPTH')) before_validation { self.timeout = nil if self.call_forward_case_id != 3 @@ -49,13 +44,6 @@ class CallForward < ActiveRecord::Base 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.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 :resolve_prerouting after_save :set_presence @@ -88,6 +76,30 @@ class CallForward < ActiveRecord::Base self.destinationable_id, delimeter, self.destinationable_type = destination_record.to_s.partition(':') end + def destination_phone_number + if self.destinationable_type.to_s.downcase == 'phonenumber' + return self.destination + end + end + + def destination_phone_number=(destination_number) + if self.destinationable_type.to_s.downcase == 'phonenumber' + self.destination = destination_number + end + end + + def destination_greeting + if self.destinationable_type.to_s.downcase == 'voicemailaccount' + return self.destination + end + end + + def destination_greeting=(destination_file) + if self.destinationable_type.to_s.downcase == 'voicemailaccount' + self.destination = destination_file + end + end + def toggle self.active = ! self.active return self.save |