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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Retain the public attribute AFTER the SetAttributeservice
Oliver Günther582e9dce07d8
diff --git a/app/services/projects/copy_service.rb b/app/services/projects/copy_service.rbindex 1888c2e3020..0f821d7b295 100644--- a/app/services/projects/copy_service.rb+++ b/app/services/projects/copy_service.rb@@ -61,6 +61,7 @@ module Projectstarget_project_params = params[:target_project_params].with_indifferent_accesscleanup_target_project_params(source, target, target_project_params)+ cleanup_target_project_attributes(source, target, target_project_params)# Assign additional params from usercall = Projects::SetAttributesService@@ -70,11 +71,19 @@ module Projectscontract_options: { copied_from: source }).call(target_project_params)- cleanup_target_project_attributes(source, target, target_project_params)+ # Retain values after the set attributes service+ retain_attributes(source, target, target_project_params)callend+ def retain_attributes(source, target, target_project_params)+ # Ensure we keep the public value of the source project+ # which might get overridden by the SetAttributesService+ # unless the user provided a different value+ target.public = source.public unless target_project_params.key?(:public)+ end+def cleanup_target_project_params(_source, _target, target_project_params)if (parent_id = target_project_params[:parent_id]) && (parent = Project.find_by(id: parent_id))target_project_params.delete(:parent_id) unless user.allowed_to?(:add_subprojects, parent)@@ -82,10 +91,6 @@ module Projectsenddef cleanup_target_project_attributes(source, target, target_project_params)- # Ensure we keep the public value of the source project- # which might get overridden by the SetAttributesService- target.public = source.public unless target_project_params.key?(:public)-if target.parenttarget.parent = nil unless user.allowed_to?(:add_subprojects, target.parent)end