Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(SPARCCatalog & SPARCDashboard) Move Service 26480 to a New Organization #205

Merged
merged 1 commit into from
Apr 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/tasks/move_service.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ task :move_service, [:service_id, :organization_id] => :environment do |t, args|
ActiveRecord::Base.transaction do
service = Service.find(args[:service_id])
dest_org = Organization.find(args[:organization_id])

# service will now belong to SSR's with this organization:
dest_org_process_ssrs = dest_org.process_ssrs_parent

Expand Down Expand Up @@ -35,20 +34,19 @@ task :move_service, [:service_id, :organization_id] => :environment do |t, args|
# ! needed, since only it will return the _other_ attributes.
copy_over_attributes = old_attributes.
slice!(*%w(id ssr_id organization_id org_tree_display status))
dest_ssr.assign_attributes(copy_over_attributes, without_protection: true)
dest_ssr.attributes = copy_over_attributes
dest_ssr.update_attribute(:organization_id, dest_org_process_ssrs.id)
dest_ssr.save(validate: false)
dest_ssr.update_org_tree
ssr.service_request.ensure_ssr_ids
end

# Move LineItems.
ssr.line_items.where(service: service).each do |li|
li.update!(sub_service_request: dest_ssr)
end
end
end
end

service.update!(organization_id: dest_org.id)
end
end
Expand Down