Updated GroupPolicy to allow moderators to perform most group actions
• Updated: - GroupPolicy to allow moderators to perform most group actions except for editing or destroying a group
This commit is contained in:
parent
2fcc99cccf
commit
d9f6a142a0
@ -29,12 +29,12 @@ class GroupPolicy < ApplicationPolicy
|
|||||||
|
|
||||||
def approve_status?
|
def approve_status?
|
||||||
check_archive!
|
check_archive!
|
||||||
is_group_admin?
|
is_group_admin_or_moderator?
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_status?
|
def destroy_status?
|
||||||
check_archive!
|
check_archive!
|
||||||
is_group_admin?
|
is_group_admin_or_moderator?
|
||||||
end
|
end
|
||||||
|
|
||||||
def join?
|
def join?
|
||||||
@ -56,19 +56,19 @@ class GroupPolicy < ApplicationPolicy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_account?
|
def update_account?
|
||||||
is_group_admin?
|
is_group_admin_or_moderator?
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_removed_accounts?
|
def show_removed_accounts?
|
||||||
is_group_admin?
|
is_group_admin_or_moderator?
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_removed_account?
|
def create_removed_account?
|
||||||
is_group_admin?
|
is_group_admin_or_moderator?
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_removed_account?
|
def destroy_removed_account?
|
||||||
is_group_admin?
|
is_group_admin_or_moderator?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -85,6 +85,10 @@ class GroupPolicy < ApplicationPolicy
|
|||||||
record.group_accounts.where(account_id: current_account.id, role: :admin).exists?
|
record.group_accounts.where(account_id: current_account.id, role: :admin).exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_group_admin_or_moderator?
|
||||||
|
record.group_accounts.where(account_id: current_account.id, role: [:moderator, :admin]).exists?
|
||||||
|
end
|
||||||
|
|
||||||
def check_archive!
|
def check_archive!
|
||||||
raise GabSocial::ValidationError, "This group has been archived." if record.is_archived
|
raise GabSocial::ValidationError, "This group has been archived." if record.is_archived
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user