blob: bc8a3e24b4f08b490f99da68f77d6b5f7e944830 (
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
32
33
34
35
36
37
38
39
40
41
  | 
class ReferentialPolicy < ApplicationPolicy
  class Scope < Scope
    def resolve
      scope
    end
  end
  def create?
    user.has_permission?('referentials.create')
  end
  def destroy?
    !archived? && organisation_match? && user.has_permission?('referentials.destroy')
  end
  def update?
    !archived? && organisation_match? && user.has_permission?('referentials.update')
  end
  def clone?
    !archived? && create?
  end
  def validate?
    !archived? && create?
  end
  def archive?
    record.archived_at.nil? && organisation_match? && user.has_permission?('referentials.update')
  end
  def unarchive?
    !record.archived_at.nil? && organisation_match? && user.has_permission?('referentials.update')
  end
  def common_lines?
    # TODO: Replace with correct BL ASA available, c.f. https://projects.af83.io/issues/2692
    true
  end
end
  |