blob: 4b2bf0cd9d0cfad6f66f3fa3ef8bdbb07df06b70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  | 
require_relative 'chain'
class TimeTablePolicy < BoivPolicy
  extend Policies::Chain
  class Scope < Scope
    def resolve
      scope
    end
  end
  chain_policies :archived?, :!, policies: %i{create? destroy? duplicate? edit?}
  def create?
      user.has_permission?('time_tables.create') # organisation match via referential is checked in the view
  end
  def edit?
      organisation_match? && user.has_permission?('time_tables.edit')
  end
  def destroy?
      organisation_match? && user.has_permission?('time_tables.destroy')
  end
  def duplicate?
      organisation_match? && create?
  end
  def update?  ; edit? end
  def new?     ; create? end
end
  |