2016-03-23 18:39:41 +01:00
|
|
|
class TrainingPolicy < ApplicationPolicy
|
|
|
|
class Scope < Scope
|
|
|
|
def resolve
|
2016-06-15 12:01:09 +02:00
|
|
|
scope.includes(:plans, :machines)
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-19 12:16:41 +02:00
|
|
|
%w(create update).each do |action|
|
2016-06-15 12:01:09 +02:00
|
|
|
define_method "#{action}?" do
|
2019-01-14 12:57:31 +01:00
|
|
|
user.admin?
|
2016-06-15 12:01:09 +02:00
|
|
|
end
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
2019-01-14 12:57:31 +01:00
|
|
|
user.admin? and record.destroyable?
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
2016-07-19 12:16:41 +02:00
|
|
|
|
|
|
|
def availabilities?
|
2019-01-14 12:57:31 +01:00
|
|
|
user.admin?
|
2016-07-19 12:16:41 +02:00
|
|
|
end
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|