UX: user preferences allows users to choose which title to use from their badges and groups

This commit is contained in:
Neil Lalonde
2018-04-06 14:29:27 -04:00
parent 10dad5de63
commit f6cfff3cea
7 changed files with 76 additions and 9 deletions

View File

@ -215,8 +215,11 @@ class Guardian
can_administer?(user) && !user.moderator?
end
def can_grant_title?(user)
user && is_staff?
def can_grant_title?(user, title = nil)
return true if user && is_staff?
return false if user != @user
return true if user.badges.where(name: title, allow_title: true).exists?
user.groups.where(title: title).exists?
end
def can_change_primary_group?(user)