2017-11-27 15:07:59 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class InvitePolicy < ApplicationPolicy
|
|
|
|
def index?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:manage_invites)
|
2017-11-27 15:07:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:invite_users)
|
2017-11-27 15:07:59 +00:00
|
|
|
end
|
|
|
|
|
2018-08-18 22:58:53 +00:00
|
|
|
def deactivate_all?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:manage_invites)
|
2018-08-18 22:58:53 +00:00
|
|
|
end
|
|
|
|
|
2017-11-27 15:07:59 +00:00
|
|
|
def destroy?
|
2022-07-05 00:41:40 +00:00
|
|
|
owner? || role.can?(:manage_invites)
|
2017-11-27 15:07:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def owner?
|
|
|
|
record.user_id == current_user&.id
|
|
|
|
end
|
|
|
|
end
|