1
我正在加入redmine 請求URI太長 請求的URL長度超過了此服務器的容量限制。每當我嘗試選擇時間表插件中的csv導出時間表報告。 我該如何解決這個問題請告訴我REDMINE TIMESHEET PLUGIN中的請求URI太長
我正在加入redmine 請求URI太長 請求的URL長度超過了此服務器的容量限制。每當我嘗試選擇時間表插件中的csv導出時間表報告。 我該如何解決這個問題請告訴我REDMINE TIMESHEET PLUGIN中的請求URI太長
問題是這個方法。您正試圖在url中檢索太多參數,並且Apache(或其他類似此類)的默認值限制爲2000個字符。在我的情況下,我沒有訪問Apache服務器,所以更改.conf文件不是一個選項。
調查倉庫的貨叉我發現已經解決了這個問題的人。 Here is a link to SashaH's pull request。 這個拉請求是相當新的,所以它還沒有提交。
只需更改代碼指示和插件應該工作,只要你想:
應用程序/傭工/ timesheet_helper.rb
:timesheet => timesheet.to_param)
end
- def link_to_csv_export(timesheet)
- link_to('CSV',
- {
- :controller => 'timesheet',
- :action => 'report',
- :format => 'csv',
- :timesheet => timesheet.to_param
- },
- :method => 'post',
- :class => 'icon icon-timesheet')
+ def form_for_csv_export(timesheet)
+ params_like_decode_url = CGI.unescape({:timesheet => timesheet.to_param}.to_query)
+ inputs = ""
+ form = form_tag :controller => 'timesheet', :action => 'report', :format => 'csv' do
+ params_like_decode_url.split("&").each do |param|
+ param_arr = param.split("=")
+ inputs << hidden_field_tag(param_arr.first, param_arr.last, :id => "")
+ end
+ inputs << submit_tag("CSV")
+ inputs.html_safe
+ end
+ form.html_safe
end
def toggle_arrows(element, js_function)
應用程序/模型/ timesheet.rb
def to_csv
out = "";
+
+ handle_time_entries = {}
+ time_entries.each do |k,v|
+ if k.is_a? String
+ handle_time_entries[k] = v
+ next;
+ end
+ handle_time_entries[k.name] = v
+ end
+
+ time_entries = handle_time_entries
FCSV.generate(out, :encoding => 'u', :force_quotes => true) do |csv|
csv << csv_header
@@ -314,7 +325,7 @@ def time_entries_for_user(user, options={})
return TimeEntry.includes(self.includes).
where(self.conditions([user], extra_conditions)).
- order('spent_on ASC')
+ order('spent_on ASC').references(self.includes)
end
def fetch_time_entries_by_project
app/views/timesheet/report.html.erb
<div class="contextual">
- <%= link_to_csv_export(@timesheet) %>
+ <%= form_for_csv_export(@timesheet) %>
<%= permalink_to_timesheet(@timesheet) %>
</div>
init.rb
require 'redmine'
## Taken from lib/redmine.rb
-#if RUBY_VERSION < '1.9'
-# require 'faster_csv'
-#else
-# require 'csv'
-# FCSV = CSV
-#end
+if RUBY_VERSION < '1.9'
+ require 'faster_csv'
+else
+ require 'csv'
+ FCSV = CSV
+end
if Rails::VERSION::MAJOR < 3
require 'dispatcher'