Commit 8bdee39e authored by jplang's avatar jplang
Browse files

Isolates csv options for a hash param (#1159).

git-svn-id: https://svn.redmine.org/redmine/trunk@14674 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 762b46e4
......@@ -79,7 +79,7 @@ class IssuesController < ApplicationController
Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
}
format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
format.csv { send_data(query_to_csv(@issues, @query, params), :type => 'text/csv; header=present', :filename => 'issues.csv') }
format.csv { send_data(query_to_csv(@issues, @query, params[:csv]), :type => 'text/csv; header=present', :filename => 'issues.csv') }
format.pdf { send_file_headers! :type => 'application/pdf', :filename => 'issues.pdf' }
end
else
......
......@@ -184,6 +184,7 @@ module QueriesHelper
end
def query_to_csv(items, query, options={})
options ||= {}
columns = (options[:columns] == 'all' ? query.available_inline_columns : query.inline_columns)
query.available_block_columns.each do |column|
if options[column.name].present?
......
......@@ -79,11 +79,11 @@
<h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3>
<%= form_tag(params.merge({:format => 'csv',:page=>nil}), :method => :get, :id => 'csv-export-form') do %>
<p>
<label><%= radio_button_tag 'columns', '', true %> <%= l(:description_selected_columns) %></label><br />
<label><%= radio_button_tag 'columns', 'all' %> <%= l(:description_all_columns) %></label>
<label><%= radio_button_tag 'csv[columns]', '', true %> <%= l(:description_selected_columns) %></label><br />
<label><%= radio_button_tag 'csv[columns]', 'all' %> <%= l(:description_all_columns) %></label>
</p>
<p>
<label><%= check_box_tag 'description', '1', @query.has_column?(:description) %> <%= l(:field_description) %></label>
<label><%= check_box_tag 'csv[description]', '1', @query.has_column?(:description) %> <%= l(:field_description) %></label>
</p>
<% if @issue_count > Setting.issues_export_limit.to_i %>
<p class="icon icon-warning">
......
......@@ -449,7 +449,7 @@ class IssuesControllerTest < ActionController::TestCase
Issue.generate!(:description => 'test_index_csv_with_description')
with_settings :default_language => 'en' do
get :index, :format => 'csv', :description => '1'
get :index, :format => 'csv', :csv => {:description => '1'}
assert_response :success
assert_not_nil assigns(:issues)
end
......@@ -472,7 +472,7 @@ class IssuesControllerTest < ActionController::TestCase
end
def test_index_csv_with_all_columns
get :index, :format => 'csv', :columns => 'all'
get :index, :format => 'csv', :csv => {:columns => 'all'}
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'text/csv; header=present', @response.content_type
......@@ -487,7 +487,7 @@ class IssuesControllerTest < ActionController::TestCase
issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
issue.save!
get :index, :format => 'csv', :columns => 'all'
get :index, :format => 'csv', :csv => {:columns => 'all'}
assert_response :success
lines = @response.body.chomp.split("\n")
assert lines.detect {|line| line.include?('"MySQL, Oracle"')}
......@@ -498,14 +498,14 @@ class IssuesControllerTest < ActionController::TestCase
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {field.id => '185.6'})
with_settings :default_language => 'fr' do
get :index, :format => 'csv', :columns => 'all'
get :index, :format => 'csv', :csv => {:columns => 'all'}
assert_response :success
issue_line = response.body.chomp.split("\n").map {|line| line.split(';')}.detect {|line| line[0]==issue.id.to_s}
assert_include '185,60', issue_line
end
with_settings :default_language => 'en' do
get :index, :format => 'csv', :columns => 'all'
get :index, :format => 'csv', :csv => {:columns => 'all'}
assert_response :success
issue_line = response.body.chomp.split("\n").map {|line| line.split(',')}.detect {|line| line[0]==issue.id.to_s}
assert_include '185.60', issue_line
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment