summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-04-17 10:26:30 +0200
committerPeter Kozak <spag@golwen.net>2013-04-17 10:26:30 +0200
commit73172e5ce8f863951476559890fdf7528037bc07 (patch)
tree6752290f9c2854148f0ee0a77a6a739b7a62219f /app
parenta1eb4fa1f6460dc2c56a5b8799cc6713f1379878 (diff)
tenant fax_accounts
Diffstat (limited to 'app')
-rw-r--r--app/controllers/fax_accounts_controller.rb5
-rw-r--r--app/models/fax_account.rb1
2 files changed, 4 insertions, 2 deletions
diff --git a/app/controllers/fax_accounts_controller.rb b/app/controllers/fax_accounts_controller.rb
index 031080e..804cdb9 100644
--- a/app/controllers/fax_accounts_controller.rb
+++ b/app/controllers/fax_accounts_controller.rb
@@ -1,7 +1,8 @@
class FaxAccountsController < ApplicationController
load_resource :user
+ load_resource :tenant
load_resource :user_group
- load_and_authorize_resource :fax_account, :through => [:user, :user_group]
+ load_and_authorize_resource :fax_account, :through => [:user, :user_group, :tenant]
before_filter :set_and_authorize_parent
before_filter :spread_breadcrumbs
@@ -54,7 +55,7 @@ class FaxAccountsController < ApplicationController
private
def set_and_authorize_parent
- @parent = @user || @user_group
+ @parent = @user || @user_group || @tenant
authorize! :read, @parent
end
diff --git a/app/models/fax_account.rb b/app/models/fax_account.rb
index 683447a..2677c5d 100644
--- a/app/models/fax_account.rb
+++ b/app/models/fax_account.rb
@@ -49,6 +49,7 @@ class FaxAccount < ActiveRecord::Base
tenant = case self.fax_accountable_type
when 'UserGroup' ; fax_accountable.tenant
when 'User' ; fax_accountable.current_tenant || fax_accountable.tenants.last
+ when 'Tenant' ; fax_accountable
else nil
end
self.tenant_id = tenant.id if tenant != nil