2022-07-19 12:07:00 +00:00
|
|
|
class MacroPolicy < ApplicationPolicy
|
|
|
|
def index?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def create?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def show?
|
2022-11-08 01:46:00 +00:00
|
|
|
@record.global? || author?
|
2022-07-19 12:07:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update?
|
2022-11-08 01:46:00 +00:00
|
|
|
author? || (@account_user.administrator? && @record.global?)
|
2022-07-19 12:07:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
2022-11-08 01:46:00 +00:00
|
|
|
author? || orphan_record?
|
2022-07-19 12:07:00 +00:00
|
|
|
end
|
2022-07-26 07:11:22 +00:00
|
|
|
|
|
|
|
def execute?
|
2022-11-08 01:46:00 +00:00
|
|
|
@record.global? || author?
|
2022-07-26 07:11:22 +00:00
|
|
|
end
|
2022-10-21 02:41:48 +00:00
|
|
|
|
|
|
|
def attach_file?
|
|
|
|
true
|
|
|
|
end
|
2022-11-08 01:46:00 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def author?
|
|
|
|
@record.created_by == @account_user.user
|
|
|
|
end
|
|
|
|
|
|
|
|
def orphan_record?
|
|
|
|
return @account_user.administrator? if @record.created_by.nil? && @record.global?
|
|
|
|
|
|
|
|
false
|
|
|
|
end
|
2022-07-19 12:07:00 +00:00
|
|
|
end
|