aboutsummaryrefslogtreecommitdiffstats
path: root/app/policies/vehicle_journey_policy.rb
blob: 785c2bb1fc43af522087d85e6d4d095660b9eb76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class VehicleJourneyPolicy < ApplicationPolicy
  class Scope < Scope
    def resolve
      scope
    end
  end

  def create?
    user.has_permission?('vehicle_journeys.create') # organisation match via referential is checked in the view
  end

  def edit?
    organisation_match?(via_referential: true) && user.has_permission?('vehicle_journeys.edit')
  end

  def destroy?
    organisation_match?(via_referential: true) && user.has_permission?('vehicle_journeys.destroy')
  end

  def update?  ; edit? end
  def new?     ; create? end
end