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

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

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

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

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