Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add attr_reader

Mir Bhatia7edb61b6925f
diff --git a/app/services/work_packages/bulk/copy_service.rb b/app/services/work_packages/bulk/copy_service.rb
index 0227f5c8050..394fd06b397 100644
--- a/app/services/work_packages/bulk/copy_service.rb
+++ b/app/services/work_packages/bulk/copy_service.rb
@@ -29,6 +29,8 @@
module WorkPackages
module Bulk
class CopyService < BulkedService
+ attr_reader :wp_map
+
def initialize(user:, work_packages:)
super
@@ -53,7 +55,7 @@ module WorkPackages
result.add_dependent!(wp_copy)
- @wp_map.store(work_package.id, wp_copy.result.id)
+ wp_map.store(work_package.id, wp_copy.result.id)
end
copy_relations unless result.failure?
@@ -63,12 +65,12 @@ module WorkPackages
end
def copy_relations
- relations = Relation.where(to_id: @wp_map.keys, from_id: @wp_map.keys)
+ relations = Relation.where(to_id: wp_map.keys, from_id: wp_map.keys)
relations.each do |relation|
new_relation = relation.dup
- new_relation.from_id = @wp_map[relation.from_id]
- new_relation.to_id = @wp_map[relation.to_id]
+ new_relation.from_id = wp_map[relation.from_id]
+ new_relation.to_id = wp_map[relation.to_id]
new_relation.save!
end
end
@@ -83,7 +85,7 @@ module WorkPackages
.each do |wp|
copied = copy_with_updated_parent_id(wp, attributes, ancestors)
- @wp_map.store(wp.id, copied.result.id)
+ wp_map.store(wp.id, copied.result.id)
result.add_dependent!(copied)
end