diff options
author | Peter Kozak <spag@golwen.net> | 2013-03-08 05:50:02 -0500 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-03-08 05:50:02 -0500 |
commit | 4d7d5ad238990582d6c90a25272f2141ea9a3b28 (patch) | |
tree | 135c475c7b0b78a8a4f78e47c97040202fbc9d1d /app/models | |
parent | 7149ddd968787eca9d05feea315d4fa3774fe54e (diff) |
toggle action added to acd_agents
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ability.rb | 5 | ||||
-rw-r--r-- | app/models/acd_agent.rb | 9 | ||||
-rw-r--r-- | app/models/sip_account.rb | 2 |
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 |