2015-10-05 70 views
1

我正在加入redmine 请求URI太长 请求的URL长度超过了此服务器的容量限制。每当我尝试选择时间表插件中的csv导出时间表报告。 我该如何解决这个问题请告诉我REDMINE TIMESHEET PLUGIN中的请求URI太长

回答

1

问题是这个方法。您正试图在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' 
相关问题