Commit 0273b79b92fb38086f14f2a44e621c37c35cc748
1 parent
be26d272
Exists in
master
and in
4 other branches
User#owned_groups is now respect group membership
Showing
1 changed file
with
2 additions
and
5 deletions
Show diff stats
app/models/user.rb
| ... | ... | @@ -74,6 +74,8 @@ class User < ActiveRecord::Base |
| 74 | 74 | |
| 75 | 75 | # Groups |
| 76 | 76 | has_many :own_groups, class_name: "Group", foreign_key: :owner_id |
| 77 | + has_many :owned_groups, through: :users_groups, source: :group, conditions: { users_groups: { group_access: UsersGroup::OWNER } } | |
| 78 | + | |
| 77 | 79 | has_many :users_groups, dependent: :destroy |
| 78 | 80 | has_many :groups, through: :users_groups |
| 79 | 81 | |
| ... | ... | @@ -225,11 +227,6 @@ class User < ActiveRecord::Base |
| 225 | 227 | end |
| 226 | 228 | end |
| 227 | 229 | |
| 228 | - # Groups where user is an owner | |
| 229 | - def owned_groups | |
| 230 | - own_groups | |
| 231 | - end | |
| 232 | - | |
| 233 | 230 | # Groups user has access to |
| 234 | 231 | def authorized_groups |
| 235 | 232 | @authorized_groups ||= begin | ... | ... |