1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/app/policies/training_policy.rb

27 lines
438 B
Ruby
Raw Normal View History

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
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
def availabilities?
2020-04-27 17:28:11 +02:00
user.admin? || user.manager?
end
2016-03-23 18:39:41 +01:00
end