admin中添加导出所有项目统计

This commit is contained in:
huang 2016-11-02 15:33:42 +08:00
parent 9d15052486
commit 928412e83d
3 changed files with 30 additions and 10 deletions

View File

@ -72,16 +72,26 @@ class RepositoriesController < ApplicationController
end
def export_rep_static
@project = Project.find(params[:id])
gpid = @project.gpid
rev = params[:rev]
cycle = params[:cycle]
respond_to do |format|
format.html
format.xls{
filename = "#{@project.name.to_s}_#{l(:label_rep_xls)}.xls"
send_data(export_rep_xls(gpid, :rev => rev, :cycle => "1"), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
# 管理员界面导出所有项目
if params[:cycle] == "admin_week" || params[:cycle] == "admin_month" || params[:cycle] == "admin_all"
if User.current.admin
projects = Project.where(:gpid => !nil)
else
render_403
end
else
@project = Project.find(params[:id])
gpid = @project.gpid
rev = params[:rev]
cycle = params[:cycle]
respond_to do |format|
format.html
format.xls{
filename = "#{@project.name.to_s}_#{l(:label_rep_xls)}.xls"
send_data(export_rep_xls(gpid, :rev => rev, :cycle => "1"), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
end
end
end

View File

@ -115,6 +115,11 @@ module ApplicationHelper
xls_report.string
end
# 管理员界面导出所有项目代码、提交次数统计
def admin_export_rep_xls
end
# 项目issue列表导出Excel功能
def issue_list_xls issues
xls_report = StringIO.new

View File

@ -77,6 +77,11 @@
</div>
<% html_title(l(:label_project_plural)) -%>
<div class="fr">项目代码/提交数统计:
<%= link_to "最近一周", {:controller => 'repositories', :action => 'export_rep_static', :format => 'xls', :rev => @rev, :cycle => "admin_week" }, :class => "linkBlue2" %> <a style="color: #7f7f7f;">|</a>
<%= link_to "最近一月", {:controller => 'repositories', :action => 'export_rep_static', :format => 'xls', :rev => @rev, :cycle => "admin_month" }, :class => "linkBlue2" %>
<%= link_to "所有", {:controller => 'repositories', :action => 'export_rep_static', :format => 'xls', :rev => @rev, :cycle => "admin_all" }, :class => "linkBlue2" %>
</div>
<script>
function delcfm() {