Defect #37735

Cannot copy project if you have a file format custom field

Added by naoki takaesu about 1 month ago. Updated 29 days ago.

Status:ConfirmedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Projects
Target version:-
Resolution: Affected version:4.2.3

Description

Steps to reproduce

  1. login as admin
  2. Create a project custom field
    1. Format -> File
    2. Name -> foo
  3. Projects -> Administration -> (choose project) -> Copy
  4. push "Copy" button

It is displayed as follows and cannot be copied

foo is invalid.

History

#1 Updated by Go MAEDA about 1 month ago

  • Status changed from New to Confirmed

#2 Updated by Takenori TAKAKI 29 days ago

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