mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: Show groups that user is owner of on groups page.
This commit is contained in:
parent
f9255631e3
commit
61111a3f9b
3 changed files with 57 additions and 6 deletions
|
@ -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]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue