mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 03:18:09 +08:00
FIX: Show groups that user is owner of on groups page.
This commit is contained in:
@ -63,6 +63,20 @@ class Group < ActiveRecord::Base
|
||||
|
||||
validates :alias_level, inclusion: { in: ALIAS_LEVELS.values}
|
||||
|
||||
scope :visible_groups, ->(user) {
|
||||
groups = Group.order(name: :asc).where("groups.id > 0")
|
||||
|
||||
if !user || !user.admin
|
||||
owner_group_ids = GroupUser.where(user: user, owner: true).pluck(:group_id)
|
||||
|
||||
groups = groups.where("
|
||||
(groups.automatic = false AND groups.visible = true) OR groups.id IN (?)
|
||||
", owner_group_ids)
|
||||
end
|
||||
|
||||
groups
|
||||
}
|
||||
|
||||
scope :mentionable, lambda {|user|
|
||||
|
||||
levels = [ALIAS_LEVELS[:everyone]]
|
||||
|
Reference in New Issue
Block a user