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

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

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

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

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