Defect #37735
open
Cannot copy project if you have a file format custom field
Added by naoki takaesu about 2 years ago.
Updated about 2 years ago.
Description
Steps to reproduce
- login as admin
- Create a project custom field
- Format ->
File
- Name ->
foo
- Projects -> Administration -> (choose project) -> Copy
- push "Copy" button
It is displayed as follows and cannot be copied
foo is invalid.
- Status changed from New to Confirmed
The following two changes will allow the project to be copied in the same way as copying an Issue.
(1) Make the custom field value copy in Project.copy_from same as Issue#copy_from.
(2) Specify multipart/form-data in the Project creation form.
The patch is as follows.
diff --git a/app/models/project.rb b/app/models/project.rb
index 81ec37d10..42d302959 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -947,7 +947,11 @@ class Project < ActiveRecord::Base
copy = Project.new(attributes)
copy.enabled_module_names = project.enabled_module_names
copy.trackers = project.trackers
- copy.custom_values = project.custom_values.collect {|v| v.clone}
+ copy.custom_field_values =
+ project.custom_field_values.inject({}) do |h, v|
+ h[v.custom_field_id] = v.value
+ h
+ end
copy.issue_custom_fields = project.issue_custom_fields
copy
end
diff --git a/app/views/projects/copy.html.erb b/app/views/projects/copy.html.erb
index 8a7805ef0..7e2ba4a47 100644
--- a/app/views/projects/copy.html.erb
+++ b/app/views/projects/copy.html.erb
@@ -1,6 +1,6 @@
<h2><%=l(:label_project_new)%></h2>
-<%= labelled_form_for @project, :url => { :action => "copy" } do |f| %>
+<%= labelled_form_for @project, :url => { :action => "copy" }, :html => {:multipart => true} do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<fieldset class="box tabular"><legend><%= toggle_checkboxes_link('.box input[type="checkbox"][name="only[]"]') %><%= l(:button_copy) %></legend>
The custom field values (files) in the file format saved in the source project will not be copied, but that is the same behavior as Issue copy.
Also available in: Atom
PDF