UX: Allow users to filter by different group types on groups page.

This commit is contained in:
Guo Xiang Tan
2018-03-20 15:50:46 +08:00
parent 63a1e9b60a
commit 15bcfcd182
10 changed files with 167 additions and 25 deletions

View File

@ -561,6 +561,16 @@ class Group < ActiveRecord::Base
STAFF_GROUPS.include?(self.name.to_sym)
end
def self.member_of(groups, user)
groups.joins(
"LEFT JOIN group_users gu ON gu.group_id = groups.id
").where("gu.user_id = ?", user.id)
end
def self.owner_of(groups, user)
self.member_of(groups, user).where("gu.owner")
end
protected
def name_format_validator