aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/compliance_check_set.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/compliance_check_set.rb')
-rw-r--r--app/models/compliance_check_set.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/app/models/compliance_check_set.rb b/app/models/compliance_check_set.rb
index 80e499b74..7c55561af 100644
--- a/app/models/compliance_check_set.rb
+++ b/app/models/compliance_check_set.rb
@@ -1,16 +1,17 @@
class ComplianceCheckSet < ActiveRecord::Base
extend Enumerize
+ has_paper_trail
belongs_to :referential
belongs_to :compliance_control_set
belongs_to :workbench
belongs_to :parent, polymorphic: true
- has_many :compliance_check_blocks
- has_many :compliance_checks
+ has_many :compliance_check_blocks, dependent: :destroy
+ has_many :compliance_checks, dependent: :destroy
- has_many :compliance_check_resources
- has_many :compliance_check_messages
+ has_many :compliance_check_resources, dependent: :destroy
+ has_many :compliance_check_messages, dependent: :destroy
enumerize :status, in: %w[new pending successful warning failed running aborted canceled]
@@ -18,6 +19,15 @@ class ComplianceCheckSet < ActiveRecord::Base
where('created_at BETWEEN :begin AND :end', begin: period_range.begin, end: period_range.end)
end
+ def notify_parent
+ if parent
+ # parent.child_change
+ update(notified_parent_at: DateTime.now)
+ else
+ errors.add(:base, I18n.t('compliance_check_sets.errors.no_parent'))
+ end
+ end
+
def update_status
statuses = compliance_check_resources.map do |resource|
case resource.status