1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-06 23:51:31 +00:00

Make Status map-able for CSV import (#22951).

git-svn-id: http://svn.redmine.org/redmine/trunk@15493 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2016-06-07 18:39:44 +00:00
parent 90d14b71b3
commit f6754a0f7a
4 changed files with 22 additions and 5 deletions

View File

@ -92,7 +92,11 @@ class IssueImport < Import
'subject' => row_value(row, 'subject'),
'description' => row_value(row, 'description')
}
attributes
if status_name = row_value(row, 'status')
if status_id = IssueStatus.named(status_name).first.try(:id)
attributes['status_id'] = status_id
end
end
issue.send :safe_attributes=, attributes, user
attributes = {}

View File

@ -9,6 +9,10 @@
<%= mapping_select_tag @import, 'tracker', :required => true,
:values => @import.allowed_target_trackers.sorted.map {|t| [t.name, t.id]} %>
</p>
<p>
<label><%= l(:field_status) %></label>
<%= mapping_select_tag @import, 'status' %>
</p>
<div class="splitcontent">
<div class="splitcontentleft">

View File

@ -1,4 +1,4 @@
priority;subject;description;start_date;due_date;parent;private;progress;custom;version;category;user;estimated_hours;tracker
High;First;First description;2015-07-08;2015-08-25;;no;;PostgreSQL;;New category;dlopper;1;bug
Normal;Child 1;Child description;;;1;yes;10;MySQL;2.0;New category;;2;feature request
Normal;Child of existing issue;Child description;;;#2;no;20;;2.1;Printing;;3;bug
priority;subject;description;start_date;due_date;parent;private;progress;custom;version;category;user;estimated_hours;tracker;status
High;First;First description;2015-07-08;2015-08-25;;no;;PostgreSQL;;New category;dlopper;1;bug;new
Normal;Child 1;Child description;;;1;yes;10;MySQL;2.0;New category;;2;feature request;new
Normal;Child of existing issue;Child description;;;#2;no;20;;2.1;Printing;;3;bug;assigned

1 priority subject description start_date due_date parent private progress custom version category user estimated_hours tracker status
2 High First First description 2015-07-08 2015-08-25 no PostgreSQL New category dlopper 1 bug new
3 Normal Child 1 Child description 1 yes 10 MySQL 2.0 New category 2 feature request new
4 Normal Child of existing issue Child description #2 no 20 2.1 Printing 3 bug assigned

View File

@ -89,6 +89,15 @@ class IssueImportTest < ActiveSupport::TestCase
assert_include "Tracker cannot be blank", item.message
end
def test_status_should_be_set
import = generate_import_with_mapping
import.mapping.merge!('status' => '14')
import.save!
issues = new_records(Issue, 3) { import.run }
assert_equal ['New', 'New', 'Assigned'], issues.map(&:status).map(&:name)
end
def test_parent_should_be_set
import = generate_import_with_mapping
import.mapping.merge!('parent_issue_id' => '5')