mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 11:14:24 +08:00
Merge pull request #2774 from okriuchykhin/ok_SCI_4829
Add task status to export all [SCI-4829]
This commit is contained in:
commit
8b0b296b90
4 changed files with 14 additions and 5 deletions
|
@ -8,7 +8,7 @@ class MyModule < ApplicationRecord
|
|||
|
||||
before_create :create_blank_protocol
|
||||
before_validation :set_completed_on, if: :state_changed?
|
||||
before_create :assign_default_status_flow
|
||||
before_validation :assign_default_status_flow
|
||||
before_save :exec_status_consequences, if: :my_module_status_id_changed?
|
||||
|
||||
auto_strip_attributes :name, :description, nullify: false
|
||||
|
@ -517,7 +517,7 @@ class MyModule < ApplicationRecord
|
|||
end
|
||||
|
||||
def assign_default_status_flow
|
||||
return unless MyModuleStatusFlow.global.any?
|
||||
return if my_module_status.present? || MyModuleStatusFlow.global.blank?
|
||||
|
||||
self.my_module_status = MyModuleStatusFlow.global.first.initial_status
|
||||
end
|
||||
|
|
|
@ -52,6 +52,7 @@ module ModelExporters
|
|||
def my_module(my_module)
|
||||
{
|
||||
my_module: my_module,
|
||||
my_module_status_name: my_module.my_module_status&.name,
|
||||
outputs: my_module.outputs,
|
||||
my_module_tags: my_module.my_module_tags,
|
||||
task_comments: my_module.task_comments,
|
||||
|
|
|
@ -646,7 +646,7 @@ class TeamImporter
|
|||
def create_my_modules(my_modules_json, experiment, user_id = nil)
|
||||
puts('Creating my_modules...')
|
||||
my_modules_json.each do |my_module_json|
|
||||
my_module = MyModule.new(my_module_json['my_module'])
|
||||
my_module = MyModule.new(my_module_json['my_module'].except('my_module_status_name'))
|
||||
orig_my_module_id = my_module.id
|
||||
my_module.id = nil
|
||||
my_module.my_module_group_id =
|
||||
|
@ -658,6 +658,16 @@ class TeamImporter
|
|||
my_module.archived_by_id = find_user(my_module.archived_by_id)
|
||||
my_module.restored_by_id = find_user(my_module.restored_by_id)
|
||||
my_module.experiment = experiment
|
||||
|
||||
# Find matching status from default flow
|
||||
default_flow = MyModuleStatusFlow.global.first
|
||||
|
||||
if default_flow.present?
|
||||
status = default_flow.my_module_statuses.find_by(name: my_module_json['my_module']['my_module_status_name'])
|
||||
status ||= default_flow.initial_status
|
||||
my_module.my_module_status = status
|
||||
end
|
||||
|
||||
my_module.save!
|
||||
@my_module_mappings[orig_my_module_id] = my_module.id
|
||||
@my_module_counter += 1
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class UserDataDeletion
|
||||
def self.delete_team_data(team)
|
||||
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
||||
Step.skip_callback(:destroy, :after, :cascade_after_destroy)
|
||||
team.transaction do
|
||||
# Destroy tiny_mce_assets
|
||||
if team.tiny_mce_assets.present?
|
||||
|
@ -86,7 +85,6 @@ class UserDataDeletion
|
|||
team.destroy!
|
||||
# raise ActiveRecord::Rollback
|
||||
end
|
||||
Step.set_callback(:destroy, :after, :cascade_after_destroy)
|
||||
end
|
||||
|
||||
def self.destroy_protocol(protocol)
|
||||
|
|
Loading…
Reference in a new issue