mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
cleans experiment form report if moved [fixes SCI-335]
This commit is contained in:
parent
da735a51f4
commit
c27c6c19e5
1 changed files with 9 additions and 13 deletions
|
@ -103,21 +103,17 @@ class ReportElement < ActiveRecord::Base
|
||||||
# removes element that are archived or deleted
|
# removes element that are archived or deleted
|
||||||
def clean_removed_or_archived_elements
|
def clean_removed_or_archived_elements
|
||||||
parent_model = ''
|
parent_model = ''
|
||||||
[ 'project',
|
%w(project experiment my_module step result checklist asset table)
|
||||||
'experiment',
|
.each do |el|
|
||||||
'my_module',
|
parent_model = el if send el
|
||||||
'step',
|
|
||||||
'result',
|
|
||||||
'checklist',
|
|
||||||
'asset',
|
|
||||||
'table'
|
|
||||||
].each do |el|
|
|
||||||
parent_model = el if self.send el
|
|
||||||
end
|
end
|
||||||
if parent_model == 'step'
|
|
||||||
self.destroy unless self.send(parent_model).completed
|
if parent_model == 'experiment'
|
||||||
|
destroy unless send(parent_model).project == report.project
|
||||||
|
elsif parent_model == 'step'
|
||||||
|
destroy unless send(parent_model).completed
|
||||||
else
|
else
|
||||||
self.destroy unless (self.send(parent_model).active? rescue self.send(parent_model))
|
destroy unless (send(parent_model).active? rescue send(parent_model))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue