Commit 0273b79b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

User#owned_groups is now respect group membership

parent be26d272
...@@ -74,6 +74,8 @@ class User < ActiveRecord::Base ...@@ -74,6 +74,8 @@ class User < ActiveRecord::Base
# Groups # Groups
has_many :own_groups, class_name: "Group", foreign_key: :owner_id has_many :own_groups, class_name: "Group", foreign_key: :owner_id
has_many :owned_groups, through: :users_groups, source: :group, conditions: { users_groups: { group_access: UsersGroup::OWNER } }
has_many :users_groups, dependent: :destroy has_many :users_groups, dependent: :destroy
has_many :groups, through: :users_groups has_many :groups, through: :users_groups
...@@ -225,11 +227,6 @@ class User < ActiveRecord::Base ...@@ -225,11 +227,6 @@ class User < ActiveRecord::Base
end end
end end
# Groups where user is an owner
def owned_groups
own_groups
end
# Groups user has access to # Groups user has access to
def authorized_groups def authorized_groups
@authorized_groups ||= begin @authorized_groups ||= begin
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment