diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-04-03 22:10:32 +0200 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-04-03 22:10:32 +0200 |
commit | 4ebbcf3b5576cc342086e2f54950a119a49f2bf9 (patch) | |
tree | e216a9634c31047e8908a882aed9ff2545ed99e6 /app/models/switchboard_entry.rb | |
parent | edf06bf6f7d4f20d5a9145a5bbf8db409fe6ab1b (diff) | |
parent | cea2cc3c1cc1e48fc4600c698d52dfda2bde4505 (diff) |
Merge branch 'emberjs' into develop
Diffstat (limited to 'app/models/switchboard_entry.rb')
-rw-r--r-- | app/models/switchboard_entry.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/models/switchboard_entry.rb b/app/models/switchboard_entry.rb index 76d002f..44de7fd 100644 --- a/app/models/switchboard_entry.rb +++ b/app/models/switchboard_entry.rb @@ -5,6 +5,8 @@ class SwitchboardEntry < ActiveRecord::Base belongs_to :switchboard, :touch => true belongs_to :sip_account, :touch => true + has_many :phone_numbers, :through => :sip_account + validates :switchboard, :presence => true @@ -28,4 +30,37 @@ class SwitchboardEntry < ActiveRecord::Base self.name.to_s end end + + def avatar_src + if self.sip_account.sip_accountable.class == User + if self.sip_account.sip_accountable.image? + self.sip_account.sip_accountable.image_url(:profile) + else + if self.sip_account.sip_accountable.male? + '/assets/icons/user-male-16x.png' + else + '/assets/icons/user-female-16x.png' + end + end + else + nil + end + end + + def callstate + if self.sip_account.call_legs.where(callstate: 'ACTIVE').any? || self.sip_account.b_call_legs.where(b_callstate: 'ACTIVE').any? + 'ACTIVE' + else + if self.sip_account.call_legs.where(callstate: 'EARLY').any? + 'EARLY' + else + if self.sip_account.call_legs.where(callstate: 'RINGING').any? + 'RINGING' + else + nil + end + end + end + end + end |