summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ability.rb5
-rw-r--r--app/models/acd_agent.rb9
-rw-r--r--app/models/sip_account.rb2
3 files changed, 16 insertions, 0 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 3cd1d4d..fe67547 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -170,6 +170,11 @@ class Ability
can :manage, Ringtone, :ringtoneable_type => 'SipAccount', :ringtoneable_id => user.sip_account_ids
can :create, Ringtone
+ # User can read and toggle status of ACD agents
+ #
+ can :read, AcdAgent, :destination_type => 'SipAccount', :destination_id => user.sip_account_ids
+ can :toggle, AcdAgent, :destination_type => 'SipAccount', :destination_id => user.sip_account_ids
+
# SoftkeyFunctions
#
can :read, SoftkeyFunction
diff --git a/app/models/acd_agent.rb b/app/models/acd_agent.rb
index 4be4700..61899f8 100644
--- a/app/models/acd_agent.rb
+++ b/app/models/acd_agent.rb
@@ -20,6 +20,15 @@ class AcdAgent < ActiveRecord::Base
self.name || I18n.t('acd_agents.name') + ' ID ' + self.id.to_s
end
+ def toggle_status
+ if self.status == 'active'
+ self.status = 'inactive'
+ else
+ self.status = 'active'
+ end
+ return self.save
+ end
+
private
def set_presence
dialplan_function = nil
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb
index 1ff3c9a..a5b8bad 100644
--- a/app/models/sip_account.rb
+++ b/app/models/sip_account.rb
@@ -41,6 +41,8 @@ class SipAccount < ActiveRecord::Base
has_many :call_legs, :class_name => 'Call'
has_many :b_call_legs, :class_name => 'Call', :foreign_key => 'b_sip_account_id'
+ has_many :acd_agents, :as => :destination, :dependent => :destroy
+
# Delegations:
#
delegate :host, :to => :sip_domain, :allow_nil => true