2020-04-27 17:28:11 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Check the access policies for API::TrainingsController
|
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
|
|
|
|
|
2020-04-27 17:28:11 +02:00
|
|
|
def create
|
|
|
|
user.admin?
|
|
|
|
end
|
|
|
|
|
|
|
|
def update?
|
|
|
|
user.admin? || user.manager?
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
2020-04-27 17:28:11 +02:00
|
|
|
user.admin? && record.destroyable?
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
2016-07-19 12:16:41 +02:00
|
|
|
|
|
|
|
def availabilities?
|
2020-04-27 17:28:11 +02:00
|
|
|
user.admin? || user.manager?
|
2016-07-19 12:16:41 +02:00
|
|
|
end
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|