diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-06-20 19:06:19 +0200 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-06-20 19:06:19 +0200 |
commit | eb0e1cc5c26275ff3e5c341404e8bc558f8312b8 (patch) | |
tree | 71f449ccd6f15422717de3ac24f87d5e888ddd79 /app/models/tenant.rb | |
parent | df6e17e48995f25e72509986f30700d778b179b6 (diff) | |
parent | 3b27a5d45b12f6bac65da2a8e17387bfda42a2f1 (diff) |
Merge branch 'develop'
Diffstat (limited to 'app/models/tenant.rb')
-rw-r--r-- | app/models/tenant.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/tenant.rb b/app/models/tenant.rb index ffa68a7..c70ec32 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -63,6 +63,10 @@ class Tenant < ActiveRecord::Base has_many :group_memberships, :as => :item, :dependent => :destroy, :uniq => true has_many :groups, :through => :group_memberships + has_many :voicemail_accounts, :as => :voicemail_accountable, :dependent => :destroy + + has_many :generic_files, :as => :owner, :dependent => :destroy + # Validations: # validates_presence_of :name, :state, :country, :language @@ -210,6 +214,14 @@ class Tenant < ActiveRecord::Base self.array_of_available_internal_extensions + self.array_of_available_dids end + def tenant_user_sip_accounts + SipAccount.where('(sip_accountable_type = "Tenant" AND sip_accountable_id = ?) OR (sip_accountable_type = "User" AND sip_accountable_id IN (?))', self.id, self.users.pluck(:id)) + end + + def tenant_user_phones + Phone.where('(phoneable_type = "Tenant" AND phoneable_id = ?) OR (phoneable_type = "User" AND phoneable_id IN (?))', self.id, self.users.pluck(:id)) + end + private # Create a public phone book for this tenant |