blob: 4b8b40b36cee11dbd2735248205e54ba22ee0c1d (
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
42
43
44
45
46
47
48
 | class ReferentialPolicy < ApplicationPolicy
  class Scope < Scope
    def resolve
      scope
    end
  end
  def browse?
    record.active? || record.archived?
  end
  def create?
    user.has_permission?('referentials.create')
  end
  def destroy?
    !referential_read_only? && organisation_match? && user.has_permission?('referentials.destroy')
  end
  def update?
    !referential_read_only? && organisation_match? && user.has_permission?('referentials.update')
  end
  def clone?
    record.ready? && !record.in_referential_suite? && create?
  end
  def validate?
    !referential_read_only? && create? && organisation_match?
  end
  def archive?
    !referential_read_only? && record.archived_at.nil? && organisation_match? && user.has_permission?('referentials.update')
  end
  def unarchive?
    record.ready? && record.archived? && !record.merged? && 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
  def referential_read_only?
    record.referential_read_only?
  end
end
 |