FEATURE: Site setting/UI to allow users to set their primary group (#8244)

* FEATURE: Site setting/ui to allow users to set their primary group

* prettier and remove logic from account template

* added 1 to 43 to make web_hook_user_serializer_spec pass
This commit is contained in:
Mark VanLandingham
2019-10-28 12:46:27 -05:00
committed by GitHub
parent 0e1c5c6bba
commit 4eb54f08b2
14 changed files with 115 additions and 6 deletions

View File

@ -316,6 +316,14 @@ class Guardian
user.groups.where(title: title).exists?
end
def can_use_primary_group?(user, group_id = nil)
return false if !user || !group_id
group = Group.find_by(id: group_id.to_i)
user.group_ids.include?(group_id.to_i) &&
(group ? !group.automatic : false)
end
def can_change_primary_group?(user)
user && is_staff?
end