Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
This commit is contained in:
commit
b588495847
|
@ -1,3 +1,4 @@
|
||||||
|
#encoding: utf-8
|
||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
|
@ -203,16 +204,51 @@ class AttachmentsController < ApplicationController
|
||||||
@attachment.save
|
@attachment.save
|
||||||
@newfiledense = filedense
|
@newfiledense = filedense
|
||||||
end
|
end
|
||||||
if @project
|
if @attachment.container_type == "Project" || @attachment.container_type == "Course"
|
||||||
|
tip_attachment_update
|
||||||
elsif @course
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def tip_attachment_update
|
||||||
|
if params[:course_id]
|
||||||
|
@tip_all_attachments = Attachment.where(:container_type => "Course", :container_id => params[:course_id])
|
||||||
|
@tip_all_public_attachments = Attachment.where(:container_type => "Course", :container_id => params[:course_id], :is_public => 1)
|
||||||
|
@tip_all_private_attachments = Attachment.where(:container_type => "Course", :container_id => params[:course_id], :is_public => 0)
|
||||||
|
@course = Course.find(params[:course_id])
|
||||||
|
elsif params[:project_id]
|
||||||
|
@tip_all_attachments = Attachment.where(:container_type => "Project", :container_id => params[:project_id])
|
||||||
|
@tip_all_public_attachments = Attachment.where(:container_type => "Project", :container_id => params[:project_id], :is_public => 1)
|
||||||
|
@tip_all_private_attachments = Attachment.where(:container_type => "Project", :container_id => params[:project_id], :is_public => 0)
|
||||||
|
@project = Project.find(params[:project_id])
|
||||||
|
end
|
||||||
|
@tag_name = params[:tag_name]
|
||||||
|
@other = params[:other]
|
||||||
|
unless @tag_name.blank?
|
||||||
|
if @other
|
||||||
|
if @project
|
||||||
|
@tip_all_attachments = @tip_all_attachments.select{|attachment| !attachment.tag_list.include?('软件版本') && !attachment.tag_list.include?('文档') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('论文') }
|
||||||
|
@tip_all_public_attachments = @tip_all_public_attachments.select{|attachment| !attachment.tag_list.include?('软件版本') && !attachment.tag_list.include?('文档') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('论文') }
|
||||||
|
@tip_all_private_attachments = @tip_all_private_attachments.select{|attachment| !attachment.tag_list.include?('软件版本') && !attachment.tag_list.include?('文档') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('论文') }
|
||||||
|
elsif @course
|
||||||
|
@tip_all_attachments = @tip_all_attachments.select{|attachment| !attachment.tag_list.include?('课件') && !attachment.tag_list.include?('软件') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('论文') }
|
||||||
|
@tip_all_public_attachments = @tip_all_public_attachments.select{|attachment| !attachment.tag_list.include?('课件') && !attachment.tag_list.include?('软件') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('论文') }
|
||||||
|
@tip_all_private_attachments = @tip_all_private_attachments.select{|attachment| !attachment.tag_list.include?('课件') && !attachment.tag_list.include?('软件') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('论文') }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@tip_all_attachments = @tip_all_attachments.select{|attachment| attachment.tag_list.include?(@tag_name)}
|
||||||
|
@tip_all_public_attachments = @tip_all_public_attachments.select{|attachment| attachment.tag_list.include?(@tag_name)}
|
||||||
|
@tip_all_private_attachments = @tip_all_private_attachments.select{|attachment| attachment.tag_list.include?(@tag_name)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@tip_all_attachments = @tip_all_attachments.count
|
||||||
|
@tip_all_public_attachments = @tip_all_public_attachments.count
|
||||||
|
@tip_all_private_attachments = @tip_all_private_attachments.count
|
||||||
|
end
|
||||||
|
|
||||||
def thumbnail
|
def thumbnail
|
||||||
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
|
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
|
||||||
if stale?(:etag => thumbnail)
|
if stale?(:etag => thumbnail)
|
||||||
|
@ -281,6 +317,7 @@ class AttachmentsController < ApplicationController
|
||||||
@attachment.delete
|
@attachment.delete
|
||||||
@flag = true
|
@flag = true
|
||||||
end
|
end
|
||||||
|
# tip_attachment_update
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
|
|
|
@ -86,19 +86,20 @@ class FilesController < ApplicationController
|
||||||
else
|
else
|
||||||
@result = find_course_attache q,@course,sort
|
@result = find_course_attache q,@course,sort
|
||||||
@result = visable_attachemnts @result
|
@result = visable_attachemnts @result
|
||||||
# @searched_attach = paginateHelper @result,10
|
# @searched_attach = paginateHelper @result,10
|
||||||
@tag_list = get_course_tag_list @course
|
@tag_list = get_course_tag_list @course
|
||||||
end
|
end
|
||||||
@all_attachments = @result
|
@all_attachments = @result
|
||||||
|
get_attachment_for_tip(@all_attachments)
|
||||||
@limit = 10
|
@limit = 10
|
||||||
@feedback_count = @all_attachments.count
|
@feedback_count = @all_attachments.count
|
||||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||||
@offset ||= @feedback_pages.offset
|
@offset ||= @feedback_pages.offset
|
||||||
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||||
@obj_attachments = paginateHelper @all_attachments,10
|
@obj_attachments = paginateHelper @all_attachments,10
|
||||||
#rescue Exception => e
|
#rescue Exception => e
|
||||||
# #render 'stores'
|
# #render 'stores'
|
||||||
# redirect_to search_course_files_url
|
# redirect_to search_course_files_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -164,6 +165,7 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
@all_attachments = @project_attachment_result
|
@all_attachments = @project_attachment_result
|
||||||
|
get_attachment_for_tip(@all_attachments)
|
||||||
@limit = 10
|
@limit = 10
|
||||||
@feedback_count = @all_attachments.count
|
@feedback_count = @all_attachments.count
|
||||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||||
|
@ -176,52 +178,52 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_files_in_subfield
|
def search_files_in_subfield
|
||||||
sort = ""
|
sort = ""
|
||||||
@sort = ""
|
@sort = ""
|
||||||
@order = ""
|
@order = ""
|
||||||
@is_remote = true
|
@is_remote = true
|
||||||
@q = params[:name].strip
|
@q = params[:name].strip
|
||||||
if params[:sort]
|
if params[:sort]
|
||||||
order_by = params[:sort].split(":")
|
order_by = params[:sort].split(":")
|
||||||
@sort = order_by[0]
|
@sort = order_by[0]
|
||||||
if order_by.count > 1
|
if order_by.count > 1
|
||||||
@order = order_by[1]
|
@order = order_by[1]
|
||||||
end
|
|
||||||
sort = "#{@sort} #{@order}"
|
|
||||||
end
|
end
|
||||||
# show_attachments [@course]
|
sort = "#{@sort} #{@order}"
|
||||||
begin
|
|
||||||
q = "%#{params[:name].strip}%"
|
|
||||||
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
|
||||||
if params[:insite]
|
|
||||||
if q == "%%"
|
|
||||||
@result = []
|
|
||||||
@searched_attach = paginateHelper @result,10
|
|
||||||
else
|
|
||||||
@result = find_public_attache q,sort
|
|
||||||
@result = visable_attachemnts_insite @result,@org_subfield
|
|
||||||
@searched_attach = paginateHelper @result,10
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@result = find_org_subfield_attache q,@org_subfield,sort
|
|
||||||
@result = visable_attachemnts @result
|
|
||||||
@searched_attach = paginateHelper @result,10
|
|
||||||
@tag_list = attachment_tag_list @result
|
|
||||||
end
|
|
||||||
#rescue Exception => e
|
|
||||||
# #render 'stores'
|
|
||||||
# redirect_to search_course_files_url
|
|
||||||
end
|
|
||||||
@page = params[:page] || 1
|
|
||||||
end
|
end
|
||||||
|
# show_attachments [@course]
|
||||||
|
begin
|
||||||
|
q = "%#{params[:name].strip}%"
|
||||||
|
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||||
|
if params[:insite]
|
||||||
|
if q == "%%"
|
||||||
|
@result = []
|
||||||
|
@searched_attach = paginateHelper @result,10
|
||||||
|
else
|
||||||
|
@result = find_public_attache q,sort
|
||||||
|
@result = visable_attachemnts_insite @result,@org_subfield
|
||||||
|
@searched_attach = paginateHelper @result,10
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@result = find_org_subfield_attache q,@org_subfield,sort
|
||||||
|
@result = visable_attachemnts @result
|
||||||
|
@searched_attach = paginateHelper @result,10
|
||||||
|
@tag_list = attachment_tag_list @result
|
||||||
|
end
|
||||||
|
#rescue Exception => e
|
||||||
|
# #render 'stores'
|
||||||
|
# redirect_to search_course_files_url
|
||||||
|
end
|
||||||
|
@page = params[:page] || 1
|
||||||
|
end
|
||||||
|
|
||||||
def find_course_attache keywords,course,sort = ""
|
def find_course_attache keywords,course,sort = ""
|
||||||
if sort == ""
|
if sort == ""
|
||||||
sort = "created_on DESC"
|
sort = "created_on DESC"
|
||||||
end
|
end
|
||||||
if keywords != "%%"
|
if keywords != "%%"
|
||||||
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
|
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
|
||||||
else
|
else
|
||||||
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort)
|
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort)
|
||||||
end
|
end
|
||||||
|
@ -250,7 +252,7 @@ class FilesController < ApplicationController
|
||||||
else
|
else
|
||||||
resultSet = Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' "). reorder(sort)
|
resultSet = Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' "). reorder(sort)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_public_attache keywords,sort = ""
|
def find_public_attache keywords,sort = ""
|
||||||
# StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map
|
# StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map
|
||||||
|
@ -260,7 +262,7 @@ class FilesController < ApplicationController
|
||||||
sort = "created_on DESC"
|
sort = "created_on DESC"
|
||||||
end
|
end
|
||||||
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND attachments.copy_from IS NULL AND filename LIKE :like ", like: "%#{keywords}%").
|
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND attachments.copy_from IS NULL AND filename LIKE :like ", like: "%#{keywords}%").
|
||||||
reorder(sort)
|
reorder(sort)
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -325,7 +327,7 @@ class FilesController < ApplicationController
|
||||||
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
|
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
|
||||||
|
|
||||||
show_attachments @containers
|
show_attachments @containers
|
||||||
# get_attachment_for_tip(@all_attachments)
|
get_attachment_for_tip(@all_attachments)
|
||||||
|
|
||||||
@tag_list = attachment_tag_list @all_attachments
|
@tag_list = attachment_tag_list @all_attachments
|
||||||
|
|
||||||
|
@ -355,7 +357,7 @@ class FilesController < ApplicationController
|
||||||
when "quotes"
|
when "quotes"
|
||||||
attribute = "quotes"
|
attribute = "quotes"
|
||||||
else
|
else
|
||||||
attribute = "created_on"
|
attribute = "created_on"
|
||||||
end
|
end
|
||||||
@sort = order_by[0]
|
@sort = order_by[0]
|
||||||
@order = order_by[1]
|
@order = order_by[1]
|
||||||
|
@ -378,7 +380,7 @@ class FilesController < ApplicationController
|
||||||
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
|
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
|
||||||
|
|
||||||
show_attachments @containers
|
show_attachments @containers
|
||||||
# get_attachment_for_tip(@all_attachments)
|
get_attachment_for_tip(@all_attachments)
|
||||||
|
|
||||||
@tag_list = attachment_tag_list @all_attachments
|
@tag_list = attachment_tag_list @all_attachments
|
||||||
|
|
||||||
|
@ -501,228 +503,228 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if params[:add_tag]
|
if params[:add_tag]
|
||||||
@addTag=true
|
@addTag=true
|
||||||
#render :back
|
#render :back
|
||||||
tag_saveEx
|
tag_saveEx
|
||||||
#render :text =>"success"
|
#render :text =>"success"
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
#modify by nwb
|
#modify by nwb
|
||||||
if @project
|
if @project
|
||||||
@addTag=false
|
@addTag=false
|
||||||
if params[:in_project_toolbar]
|
if params[:in_project_toolbar]
|
||||||
@in_project_toolbar = params[:in_project_toolbar]
|
@in_project_toolbar = params[:in_project_toolbar]
|
||||||
end
|
end
|
||||||
attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type])
|
attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type])
|
||||||
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||||
# 发送邮件
|
# 发送邮件
|
||||||
Mailer.run.attachments_added(attachments[:files])
|
Mailer.run.attachments_added(attachments[:files])
|
||||||
# 生成动态
|
# 生成动态
|
||||||
attachments[:files].each do |file|
|
attachments[:files].each do |file|
|
||||||
ForgeActivity.create(:user_id => User.current.id, :project_id => @project.id, :forge_act_id => file.id, :forge_act_type => "Attachment")
|
ForgeActivity.create(:user_id => User.current.id, :project_id => @project.id, :forge_act_id => file.id, :forge_act_type => "Attachment")
|
||||||
end
|
end
|
||||||
# 更新资源总数, 根据上传的附件数累加
|
# 更新资源总数, 根据上传的附件数累加
|
||||||
@project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) unless @project.project_score.nil?
|
@project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) unless @project.project_score.nil?
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
if params[:project_attachment_type] && params[:project_attachment_type].is_a?(Array)
|
if params[:project_attachment_type] && params[:project_attachment_type].is_a?(Array)
|
||||||
params[:project_attachment_type].each do |type|
|
params[:project_attachment_type].each do |type|
|
||||||
tag_name = get_project_tag_name_by_type_nmuber type
|
tag_name = get_project_tag_name_by_type_nmuber type
|
||||||
if !attachments.empty? && attachments[:files] && tag_name != ""
|
if !attachments.empty? && attachments[:files] && tag_name != ""
|
||||||
attachments[:files].each do |attachment|
|
attachments[:files].each do |attachment|
|
||||||
attachment.tag_list.add(tag_name)
|
attachment.tag_list.add(tag_name)
|
||||||
attachment.description = params[:description]
|
attachment.description = params[:description]
|
||||||
attachment.save
|
attachment.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if params[:project_attachment_type] && params[:project_attachment_type] != "6"
|
if params[:project_attachment_type] && params[:project_attachment_type] != "6"
|
||||||
tag_name = get_project_tag_name_by_type_nmuber params[:project_attachment_type]
|
tag_name = get_project_tag_name_by_type_nmuber params[:project_attachment_type]
|
||||||
if !attachments.empty? && attachments[:files] && tag_name != ""
|
if !attachments.empty? && attachments[:files] && tag_name != ""
|
||||||
attachments[:files].each do |attachment|
|
attachments[:files].each do |attachment|
|
||||||
attachment.tag_list.add(tag_name)
|
attachment.tag_list.add(tag_name)
|
||||||
attachment.description = params[:description]
|
attachment.description = params[:description]
|
||||||
attachment.save
|
attachment.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# TODO: 临时用 nyan
|
# TODO: 临时用 nyan
|
||||||
sort_init 'created_on', 'desc'
|
sort_init 'created_on', 'desc'
|
||||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||||
'filename' => "#{Attachment.table_name}.filename",
|
'filename' => "#{Attachment.table_name}.filename",
|
||||||
'size' => "#{Attachment.table_name}.filesize",
|
'size' => "#{Attachment.table_name}.filesize",
|
||||||
'downloads' => "#{Attachment.table_name}.downloads"
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||||||
|
|
||||||
@containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
|
@containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
|
||||||
show_attachments @containers
|
show_attachments @containers
|
||||||
@tag_list = attachment_tag_list @all_attachments
|
@tag_list = attachment_tag_list @all_attachments
|
||||||
@attachtype = 0
|
@attachtype = 0
|
||||||
@contenttype = 0
|
@contenttype = 0
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
format.html {
|
format.html {
|
||||||
redirect_to project_files_url(@project)
|
redirect_to project_files_url(@project)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
elsif @course
|
elsif @course
|
||||||
@addTag=false
|
@addTag=false
|
||||||
if params[:in_course_toolbar]
|
if params[:in_course_toolbar]
|
||||||
@in_course_toolbar = params[:in_course_toolbar]
|
@in_course_toolbar = params[:in_course_toolbar]
|
||||||
end
|
end
|
||||||
attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type])
|
attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type])
|
||||||
|
|
||||||
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||||
Mailer.run.attachments_added(attachments[:files])
|
Mailer.run.attachments_added(attachments[:files])
|
||||||
end
|
end
|
||||||
if !attachments.empty? && attachments[:files]
|
if !attachments.empty? && attachments[:files]
|
||||||
attachments[:files].each do |attachment|
|
attachments[:files].each do |attachment|
|
||||||
if params[:publish_time]
|
if params[:publish_time]
|
||||||
if params[:publish_time] == ""
|
if params[:publish_time] == ""
|
||||||
attachment.publish_time = Date.today
|
attachment.publish_time = Date.today
|
||||||
else
|
else
|
||||||
attachment.publish_time = params[:publish_time]
|
attachment.publish_time = params[:publish_time]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
attachment.publish_time = Date.today
|
attachment.publish_time = Date.today
|
||||||
end
|
end
|
||||||
if attachment.publish_time > Date.today
|
if attachment.publish_time > Date.today
|
||||||
attachment.is_publish = 0
|
attachment.is_publish = 0
|
||||||
end
|
end
|
||||||
attachment.description = params[:description]
|
attachment.description = params[:description]
|
||||||
attachment.save
|
attachment.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
|
if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
|
||||||
params[:course_attachment_type].each do |type|
|
params[:course_attachment_type].each do |type|
|
||||||
tag_name = get_tag_name_by_type_number type
|
tag_name = get_tag_name_by_type_number type
|
||||||
if !attachments.empty? && attachments[:files] && tag_name != ""
|
if !attachments.empty? && attachments[:files] && tag_name != ""
|
||||||
attachments[:files].each do |attachment|
|
attachments[:files].each do |attachment|
|
||||||
attachment.tag_list.add(tag_name)
|
attachment.tag_list.add(tag_name)
|
||||||
attachment.save
|
attachment.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if params[:course_attachment_type] && params[:course_attachment_type] != "5"
|
if params[:course_attachment_type] && params[:course_attachment_type] != "5"
|
||||||
tag_name = get_tag_name_by_type_number params[:course_attachment_type]
|
tag_name = get_tag_name_by_type_number params[:course_attachment_type]
|
||||||
if !attachments.empty? && attachments[:files] && tag_name != ""
|
if !attachments.empty? && attachments[:files] && tag_name != ""
|
||||||
attachments[:files].each do |attachment|
|
attachments[:files].each do |attachment|
|
||||||
attachment.tag_list.add(tag_name)
|
attachment.tag_list.add(tag_name)
|
||||||
attachment.save
|
attachment.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# 更新课程英雄榜得分
|
# 更新课程英雄榜得分
|
||||||
course_member_score(@course.id, attachments[:files].first.author_id, "Attachment")
|
course_member_score(@course.id, attachments[:files].first.author_id, "Attachment")
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
# TODO: 临时用 nyan
|
# TODO: 临时用 nyan
|
||||||
sort_init 'created_on', 'desc'
|
sort_init 'created_on', 'desc'
|
||||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||||
'filename' => "#{Attachment.table_name}.filename",
|
'filename' => "#{Attachment.table_name}.filename",
|
||||||
'size' => "#{Attachment.table_name}.filesize",
|
'size' => "#{Attachment.table_name}.filesize",
|
||||||
'downloads' => "#{Attachment.table_name}.downloads"
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||||||
|
|
||||||
@containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
@containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
||||||
|
|
||||||
show_attachments @containers
|
show_attachments @containers
|
||||||
@tag_list = attachment_tag_list @all_attachments
|
@tag_list = attachment_tag_list @all_attachments
|
||||||
|
|
||||||
@attachtype = 0
|
@attachtype = 0
|
||||||
@contenttype = 0
|
@contenttype = 0
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
format.html {
|
format.html {
|
||||||
redirect_to course_files_url(@course)
|
redirect_to course_files_url(@course)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
elsif @org_subfield
|
elsif @org_subfield
|
||||||
@addTag=false
|
@addTag=false
|
||||||
attachments = Attachment.attach_filesex(@org_subfield, params[:attachments], params[:org_subfield_attachment_type])
|
attachments = Attachment.attach_filesex(@org_subfield, params[:attachments], params[:org_subfield_attachment_type])
|
||||||
|
|
||||||
if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type].is_a?(Array)
|
if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type].is_a?(Array)
|
||||||
params[:org_subfield_attachment_type].each do |type|
|
params[:org_subfield_attachment_type].each do |type|
|
||||||
tag_name = get_tag_name_by_type_number type
|
tag_name = get_tag_name_by_type_number type
|
||||||
if !attachments.empty? && attachments[:files] && tag_name != ""
|
if !attachments.empty? && attachments[:files] && tag_name != ""
|
||||||
attachments[:files].each do |attachment|
|
attachments[:files].each do |attachment|
|
||||||
attachment.tag_list.add(tag_name)
|
attachment.tag_list.add(tag_name)
|
||||||
attachment.description = params[:description]
|
attachment.description = params[:description]
|
||||||
attachment.save
|
attachment.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type] != "5"
|
if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type] != "5"
|
||||||
tag_name = get_tag_name_by_type_number params[:org_subfield_attachment_type]
|
tag_name = get_tag_name_by_type_number params[:org_subfield_attachment_type]
|
||||||
if !attachments.empty? && attachments[:files] && tag_name != ""
|
if !attachments.empty? && attachments[:files] && tag_name != ""
|
||||||
attachments[:files].each do |attachment|
|
attachments[:files].each do |attachment|
|
||||||
attachment.tag_list.add(tag_name)
|
attachment.tag_list.add(tag_name)
|
||||||
attachment.description = params[:description]
|
attachment.description = params[:description]
|
||||||
attachment.save
|
attachment.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: 临时用 nyan
|
# TODO: 临时用 nyan
|
||||||
sort_init 'created_on', 'desc'
|
sort_init 'created_on', 'desc'
|
||||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||||
'filename' => "#{Attachment.table_name}.filename",
|
'filename' => "#{Attachment.table_name}.filename",
|
||||||
'size' => "#{Attachment.table_name}.filesize",
|
'size' => "#{Attachment.table_name}.filesize",
|
||||||
'downloads' => "#{Attachment.table_name}.downloads"
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||||||
|
|
||||||
@containers = [OrgSubfield.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@org_subfield.id)]
|
@containers = [OrgSubfield.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@org_subfield.id)]
|
||||||
|
|
||||||
show_attachments @containers
|
show_attachments @containers
|
||||||
@tag_list = attachment_tag_list @all_attachments
|
@tag_list = attachment_tag_list @all_attachments
|
||||||
@attachtype = 0
|
@attachtype = 0
|
||||||
@contenttype = 0
|
@contenttype = 0
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
# format.html {
|
# format.html {
|
||||||
# redirect_to org_subfield_files_url(@org_subfield)
|
# redirect_to org_subfield_files_url(@org_subfield)
|
||||||
# }
|
# }
|
||||||
end
|
end
|
||||||
# 组织添加附件,为了修改图片
|
# 组织添加附件,为了修改图片
|
||||||
elsif params[:organization_id]
|
elsif params[:organization_id]
|
||||||
@organization = Organization.find(params[:organization_id])
|
@organization = Organization.find(params[:organization_id])
|
||||||
@addTag=false
|
@addTag=false
|
||||||
# atttchment_type = 0为logo 1为banner
|
# atttchment_type = 0为logo 1为banner
|
||||||
if params[:logo]
|
if params[:logo]
|
||||||
attachments = Attachment.attach_filesex(@organization, params[:attachments], false)
|
attachments = Attachment.attach_filesex(@organization, params[:attachments], false)
|
||||||
else
|
else
|
||||||
attachments = Attachment.attach_filesex(@organization, params[:attachments], true)
|
attachments = Attachment.attach_filesex(@organization, params[:attachments], true)
|
||||||
end
|
end
|
||||||
# TODO: 临时用 nyan
|
# TODO: 临时用 nyan
|
||||||
sort_init 'created_on', 'desc'
|
sort_init 'created_on', 'desc'
|
||||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||||
'filename' => "#{Attachment.table_name}.filename",
|
'filename' => "#{Attachment.table_name}.filename",
|
||||||
'size' => "#{Attachment.table_name}.filesize",
|
'size' => "#{Attachment.table_name}.filesize",
|
||||||
'downloads' => "#{Attachment.table_name}.downloads"
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||||||
|
|
||||||
@containers = [Organization.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@organization.id)]
|
@containers = [Organization.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@organization.id)]
|
||||||
|
|
||||||
show_attachments @containers
|
show_attachments @containers
|
||||||
@tag_list = attachment_tag_list @all_attachments
|
@tag_list = attachment_tag_list @all_attachments
|
||||||
@attachtype = 0
|
@attachtype = 0
|
||||||
@contenttype = 0
|
@contenttype = 0
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
# format.html {
|
# format.html {
|
||||||
# redirect_to org_subfield_files_url(@org_subfield)
|
# redirect_to org_subfield_files_url(@org_subfield)
|
||||||
# }
|
# }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_project_tag_name_by_type_nmuber type
|
def get_project_tag_name_by_type_nmuber type
|
||||||
|
@ -798,13 +800,13 @@ class FilesController < ApplicationController
|
||||||
else
|
else
|
||||||
#捕获异常
|
#捕获异常
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# 返回指定资源类型的资源列表
|
# 返回指定资源类型的资源列表
|
||||||
# added by nwb
|
# added by nwb
|
||||||
def getattachtype
|
def getattachtype
|
||||||
sort_init 'created_on', 'desc'
|
sort_init 'created_on', 'desc'
|
||||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||||
'filename' => "#{Attachment.table_name}.filename",
|
'filename' => "#{Attachment.table_name}.filename",
|
||||||
'size' => "#{Attachment.table_name}.filesize",
|
'size' => "#{Attachment.table_name}.filesize",
|
||||||
'downloads' => "#{Attachment.table_name}.downloads"
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||||||
|
@ -842,27 +844,27 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @project
|
if @project
|
||||||
@isproject = true
|
@isproject = true
|
||||||
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
|
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
|
||||||
@containers += @project.versions.includes(:attachments).reorder(sort).all
|
@containers += @project.versions.includes(:attachments).reorder(sort).all
|
||||||
show_attachments @containers
|
show_attachments @containers
|
||||||
@attachtype = params[:type].to_i
|
@attachtype = params[:type].to_i
|
||||||
@contenttype = params[:contentType].to_s
|
@contenttype = params[:contentType].to_s
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
format.html {
|
format.html {
|
||||||
render :layout => 'base_projects'
|
render :layout => 'base_projects'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
elsif @course
|
elsif @course
|
||||||
@isproject = false
|
@isproject = false
|
||||||
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
|
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
|
||||||
show_attachments @containers
|
show_attachments @containers
|
||||||
@attachtype = params[:type].to_i
|
@attachtype = params[:type].to_i
|
||||||
@contenttype = params[:contentType].to_s
|
@contenttype = params[:contentType].to_s
|
||||||
# render layout: 'base_courses'
|
# render layout: 'base_courses'
|
||||||
@left_nav_type = 5
|
@left_nav_type = 5
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
|
@ -870,19 +872,19 @@ class FilesController < ApplicationController
|
||||||
render :layout => 'base_courses'
|
render :layout => 'base_courses'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
show_attachments @containers
|
show_attachments @containers
|
||||||
@attachtype = params[:type].to_i
|
@attachtype = params[:type].to_i
|
||||||
@contenttype = params[:contentType].to_s
|
@contenttype = params[:contentType].to_s
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#查找指定TAG的按条件过滤的资源列表,只有课程内搜索有此功能
|
#查找指定TAG的按条件过滤的资源列表,只有课程内搜索有此功能
|
||||||
def search_tag_attachment
|
def search_tag_attachment
|
||||||
@q,@tag_name,@order = params[:q],params[:tag_name]
|
@q,@tag_name,@order = params[:q],params[:tag_name]
|
||||||
@is_remote = true
|
@is_remote = true
|
||||||
|
|
|
@ -16,8 +16,8 @@ class QualityAnalysisController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# params 说明:{identifier:版本库名}
|
# params 说明:{identifier:版本库名}
|
||||||
|
# type: 1 新的分析 2 重新分析
|
||||||
def create
|
def create
|
||||||
logger.info("11111111111111111111111111111")
|
|
||||||
begin
|
begin
|
||||||
user_name = User.find(params[:user_id]).try(:login)
|
user_name = User.find(params[:user_id]).try(:login)
|
||||||
identifier = params[:identifier]
|
identifier = params[:identifier]
|
||||||
|
@ -30,98 +30,98 @@ class QualityAnalysisController < ApplicationController
|
||||||
# 考虑到历史数据:有些用户创建类job但是build失败,即sonar没有结果,这个时候需要把job删除,并且删掉quality_analyses表数据
|
# 考虑到历史数据:有些用户创建类job但是build失败,即sonar没有结果,这个时候需要把job删除,并且删掉quality_analyses表数据
|
||||||
# 如果不要这句则需要迁移数据
|
# 如果不要这句则需要迁移数据
|
||||||
@sonar_address = Redmine::Configuration['sonar_address']
|
@sonar_address = Redmine::Configuration['sonar_address']
|
||||||
projects_date = open(@sonar_address + "/api/projects/index").read
|
# projects_date = open(@sonar_address + "/api/projects/index").read
|
||||||
arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
|
# arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
|
||||||
quality_an = QualityAnalysis.where(:sonar_name => sonar_name).first
|
quality_an = QualityAnalysis.where(:sonar_name => sonar_name)
|
||||||
if @client_jenkins.job.exists?(job_name) && QualityAnalysis.where(:sonar_name => sonar_name).select{|qa| arr.include?(qa.sonar_name)}.blank?
|
# if @client_jenkins.job.exists?(job_name) && QualityAnalysis.where(:sonar_name => sonar_name).select{|qa| arr.include?(qa.sonar_name)}.blank?
|
||||||
aa = @client_jenkins.job.delete("#{job_name}")
|
# aa = @client_jenkins.job.delete("#{job_name}")
|
||||||
quality_an.delete unless quality_an.blank?
|
# quality_an.delete unless quality_an.blank?
|
||||||
end
|
# end
|
||||||
|
|
||||||
|
# type 1的时候之所以判断job是否存在,为了防止特殊情况,正常情况是不会出现的
|
||||||
|
# 重新分析的时候需要删除以前的分析结果
|
||||||
|
@client_jenkins.job.delete("#{job_name}") if @client_jenkins.job.exists?(job_name)
|
||||||
|
quality_an.delete_all unless quality_an.blank?
|
||||||
|
|
||||||
# Checks if the given job exists in Jenkins.
|
# Checks if the given job exists in Jenkins.
|
||||||
unless @client_jenkins.job.exists?(job_name)
|
@g = Gitlab.client
|
||||||
@g = Gitlab.client
|
branch = params[:branch]
|
||||||
branch = params[:branch]
|
language = swith_language_type(params[:language])
|
||||||
language = swith_language_type(params[:language])
|
path = params[:path].blank? ? "./" : params[:path]
|
||||||
path = params[:path].blank? ? "./" : params[:path]
|
# qa = QualityAnalysis.where(:project_id => @project.id, :author_login => user_name).first
|
||||||
# qa = QualityAnalysis.where(:project_id => @project.id, :author_login => user_name).first
|
version = 1
|
||||||
version = quality_an.nil? ? 1 : quality_an.sonar_version + 1
|
properties = "sonar.projectKey=#{sonar_name}
|
||||||
properties = "sonar.projectKey=#{sonar_name}
|
|
||||||
sonar.projectName=#{sonar_name}
|
sonar.projectName=#{sonar_name}
|
||||||
sonar.projectVersion=#{version}
|
sonar.projectVersion=#{version}
|
||||||
sonar.sources=#{path}
|
sonar.sources=#{path}
|
||||||
sonar.language=#{language.downcase}
|
sonar.language=#{language.downcase}
|
||||||
sonar.sourceEncoding=utf-8"
|
sonar.sourceEncoding=utf-8"
|
||||||
git_url = @gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git"
|
git_url = @gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git"
|
||||||
|
|
||||||
# 替换配置文件
|
# 替换配置文件
|
||||||
@doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml')))
|
@doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml')))
|
||||||
@doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url
|
@doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url
|
||||||
@doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}"
|
@doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}"
|
||||||
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties
|
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties
|
||||||
|
|
||||||
# jenkins job创建
|
# jenkins job创建
|
||||||
jenkins_job = @client_jenkins.job.create("#{job_name}", @doc.to_xml)
|
jenkins_job = @client_jenkins.job.create("#{job_name}", @doc.to_xml)
|
||||||
logger.info("Jenkins status of create ==> #{jenkins_job}")
|
|
||||||
|
|
||||||
# 将地址作为hook值添加到gitlab
|
# 将地址作为hook值添加到gitlab
|
||||||
@g.add_project_hook(@project.gpid, @jenkins_address + "/project/#{job_name}")
|
# @g.add_project_hook(@project.gpid, @jenkins_address + "/project/#{job_name}")
|
||||||
# job创建完成后自动运行job,如果运行成功则返回‘200’
|
# job创建完成后自动运行job,如果运行成功则返回‘200’
|
||||||
code = @client_jenkins.job.build("#{job_name}")
|
code = @client_jenkins.job.build("#{job_name}")
|
||||||
logger.error("build result ==> #{code}")
|
|
||||||
|
|
||||||
# 判断调用sonar分析是否成功
|
# 判断调用sonar分析是否成功
|
||||||
# 等待启动时间处理, 最长时间为30分钟
|
# 等待启动时间处理, 最长时间为30分钟
|
||||||
for i in 0..360 do
|
for i in 0..360 do
|
||||||
sleep(5)
|
sleep(5)
|
||||||
@current_build_status = @client_jenkins.job.get_current_build_status("#{job_name}")
|
@current_build_status = @client_jenkins.job.get_current_build_status("#{job_name}")
|
||||||
if (@current_build_status == "success" || @current_build_status == "failure")
|
if (@current_build_status == "success" || @current_build_status == "failure")
|
||||||
|
break
|
||||||
|
if i == 360
|
||||||
|
@build_console_result = false
|
||||||
break
|
break
|
||||||
if i == 360
|
|
||||||
@build_console_result = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# sonar 缓冲,sonar生成数据
|
|
||||||
sleep(10)
|
|
||||||
|
|
||||||
# 获取sonar output结果
|
|
||||||
console_build = @client_jenkins.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["output"]
|
|
||||||
logger.info("@current_build_status is ==> #{@current_build_status}")
|
|
||||||
|
|
||||||
# 两种情况需要删除job:
|
|
||||||
# 1/创建成功但是build失败则删除job
|
|
||||||
# 2/creat和build成功,调用sonar启动失败则删除job
|
|
||||||
# 错误信息存储需存到Trustie数据库,否则一旦job删除则无法获取这些信息
|
|
||||||
if jenkins_job == '200' && code != '201'
|
|
||||||
@client_jenkins.job.delete("#{job_name}")
|
|
||||||
else
|
|
||||||
if @current_build_status == "failure"
|
|
||||||
reg_console = /Exception:.*?\r/.match(console_build)
|
|
||||||
output = reg_console[0].gsub("\r", "") unless reg_console.nil?
|
|
||||||
se = SonarError.where(:jenkins_job_name => job_name).first
|
|
||||||
se.nil? ? SonarError.create(:project_id => @project.id, :jenkins_job_name => job_name, :output => output) : se.update_column(:output, output)
|
|
||||||
@client_jenkins.job.delete("#{job_name}")
|
|
||||||
elsif @current_build_status == "success"
|
|
||||||
if quality_an.blank?
|
|
||||||
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier,
|
|
||||||
:sonar_version => version, :path => path, :branch => branch, :language => language, :sonar_name => "#{user_name}:#{rep_id}")
|
|
||||||
else
|
|
||||||
qa.update_attribute(:sonar_version, version)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
if @current_build_status == "success"
|
|
||||||
format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)}
|
|
||||||
elsif @current_build_status == "failure"
|
|
||||||
format.html{redirect_to error_list_project_quality_analysi_path(:project_id => @project.id, :job_name => job_name)}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# sonar 缓冲,sonar生成数据
|
||||||
|
sleep(10)
|
||||||
|
|
||||||
|
# 获取sonar output结果
|
||||||
|
console_build = @client_jenkins.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["output"]
|
||||||
|
logger.info("@current_build_status is ==> #{@current_build_status}")
|
||||||
|
|
||||||
|
# 两种情况需要删除job:
|
||||||
|
# 1/创建成功但是build失败则删除job
|
||||||
|
# 2/creat和build成功,调用sonar启动失败则删除job
|
||||||
|
# 错误信息存储需存到Trustie数据库,否则一旦job删除则无法获取这些信息
|
||||||
|
if jenkins_job == '200' && code != '201'
|
||||||
|
@client_jenkins.job.delete("#{job_name}")
|
||||||
|
else
|
||||||
|
if @current_build_status == "failure"
|
||||||
|
reg_console = /Exception:.*?\r/.match(console_build)
|
||||||
|
output = reg_console[0].gsub("\r", "") unless reg_console.nil?
|
||||||
|
se = SonarError.where(:jenkins_job_name => job_name).first
|
||||||
|
se.nil? ? SonarError.create(:project_id => @project.id, :jenkins_job_name => job_name, :output => output) : se.update_column(:output, output)
|
||||||
|
@client_jenkins.job.delete("#{job_name}")
|
||||||
|
elsif @current_build_status == "success"
|
||||||
|
if quality_an.blank?
|
||||||
|
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier,
|
||||||
|
:sonar_version => version, :path => path, :branch => branch, :language => language, :sonar_name => "#{user_name}:#{rep_id}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @current_build_status == "success"
|
||||||
|
format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)}
|
||||||
|
elsif @current_build_status == "failure"
|
||||||
|
format.html{redirect_to error_list_project_quality_analysi_path(:project_id => @project.id, :job_name => job_name)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
rescue => e
|
rescue => e
|
||||||
@message = e.message
|
@message = e.message
|
||||||
logger.error("######################====>#{e.message}")
|
logger.error("######################====>#{e.message}")
|
||||||
|
@ -302,10 +302,8 @@ class QualityAnalysisController < ApplicationController
|
||||||
@jenkins_address = Redmine::Configuration['jenkins_address']
|
@jenkins_address = Redmine::Configuration['jenkins_address']
|
||||||
jenkins_username = Redmine::Configuration['jenkins_username']
|
jenkins_username = Redmine::Configuration['jenkins_username']
|
||||||
jenkins_password = Redmine::Configuration['jenkins_password']
|
jenkins_password = Redmine::Configuration['jenkins_password']
|
||||||
logger.info("22222222222222222222222222222222")
|
|
||||||
# connect jenkins
|
# connect jenkins
|
||||||
@client_jenkins = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => jenkins_username, :password => jenkins_password)
|
@client_jenkins = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => jenkins_username, :password => jenkins_password)
|
||||||
logger.info("333333333333333333333333333333")
|
|
||||||
rescue => e
|
rescue => e
|
||||||
logger.error("failed to connect Jenkins ==> #{e}")
|
logger.error("failed to connect Jenkins ==> #{e}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
<% if @attachment.container_type == 'Course' %>
|
<% if @attachment.container_type == 'Course' %>
|
||||||
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)),
|
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id, :course_id => @attachment.container_id, :tag_name => @tag_name, :other => @other,:newtype=>(@attachment.is_public? ? 0:1)),
|
||||||
:remote=>true,:class=>"postOptionLink",:method => :post) %>");
|
:remote=>true,:class=>"postOptionLink",:method => :post) %>");
|
||||||
|
$("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
|
||||||
<% elsif @attachment.container_type == 'Project' %>
|
<% elsif @attachment.container_type == 'Project' %>
|
||||||
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => @attachment.id, :newtype => (@attachment.is_public? ? 0:1)),
|
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => @attachment.id, :project_id => @attachment.container_id, :tag_name => @tag_name, :other => @other ,:newtype => (@attachment.is_public? ? 0:1)),
|
||||||
:remote => true, :class => "postOptionLink", :method => :post) %>");
|
:remote => true, :class => "postOptionLink", :method => :post) %>");
|
||||||
|
$("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
|
||||||
|
|
||||||
<% else %>
|
<% else %>
|
||||||
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)),
|
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)),
|
||||||
:remote=>true,:class=>"postOptionLink",:method => :post) %>");
|
:remote=>true,:class=>"postOptionLink",:method => :post) %>");
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @attachment.is_public? %>
|
<% if @attachment.is_public? %>
|
||||||
$("#image_private_<%= @attachment.id%>").html('')
|
$("#image_private_<%= @attachment.id%>").html('')
|
||||||
<%else%>
|
<%else%>
|
||||||
$("#image_private_<%= @attachment.id%>").html('<span class="img_private ml5">私有</span>')
|
$("#image_private_<%= @attachment.id%>").html('<span class="img_private ml5">私有</span>')
|
||||||
<% end %>
|
<% end %>
|
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$("#RSide").removeAttr("id")
|
$("#RSide").removeAttr("id")
|
||||||
$("#container").css('width',"1000px")
|
$("#container").css('width',"1000px")
|
||||||
});
|
});
|
||||||
function searchone4reload(fileid){
|
function searchone4reload(fileid){
|
||||||
var url = "<%= searchone4reload_course_files_path(@course)%>";
|
var url = "<%= searchone4reload_course_files_path(@course)%>";
|
||||||
var data = {};data.fileid=fileid;
|
var data = {};data.fileid=fileid;
|
||||||
|
@ -115,25 +115,24 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="re_con_top">
|
<div class="re_con_top">
|
||||||
<!--<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">-->
|
<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">
|
||||||
<!--<%#= render :partial => "files/tip_attachment_count" %>-->
|
<%= render :partial => "files/tip_attachment_count" %>
|
||||||
<!--</p>-->
|
</p>
|
||||||
<p class="f_l fontBlue f_b f_14">共有 <span id="attachment_count"><%= @all_attachments.count%></span> 个资源</p>
|
|
||||||
<p class="f_r" style="color: #808080" id="course_filter_order">
|
<p class="f_r" style="color: #808080" id="course_filter_order">
|
||||||
<%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>
|
<%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<!--<div class="resource_tip_box fontGrey2">-->
|
<div class="resource_tip_box fontGrey2">
|
||||||
<!--<em></em>-->
|
<em></em>
|
||||||
<!--<span></span>-->
|
<span></span>
|
||||||
<!--<p class="mb5">私有资源:<br/>仅对本班级成员可见</p>-->
|
<p class="mb5">私有资源:<br/>仅对本班级成员可见</p>
|
||||||
<!--<p>公共资源:<br/>对所有用户可见</p>-->
|
<p>公共资源:<br/>对所有用户可见</p>
|
||||||
<!--</div>-->
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="course_list">
|
<div id="course_list">
|
||||||
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
|
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%# html_title(l(:label_attachment_plural)) -%>
|
<%# html_title(l(:label_attachment_plural)) -%>
|
|
@ -85,10 +85,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="re_con_top">
|
<div class="re_con_top">
|
||||||
<!--<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">-->
|
<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">
|
||||||
<!--<%#= render :partial => "files/tip_attachment_count" %>-->
|
<%= render :partial => "files/tip_attachment_count" %>
|
||||||
<!--</p>-->
|
</p>
|
||||||
<p class="f_l fontBlue f_b f_14">共有 <span id="attachment_count"><%= @all_attachments.count%></span> 个资源</p>
|
|
||||||
<p class="f_r" style="color: #808080">
|
<p class="f_r" style="color: #808080">
|
||||||
<% if @order == "asc" %>
|
<% if @order == "asc" %>
|
||||||
按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
|
按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
|
||||||
|
@ -103,14 +102,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<%# if !User.current.member_of?(@project) && show_attachment_tip(@project.id, "Project") %>
|
<% if !User.current.member_of?(@project) && show_attachment_tip(@project.id, "Project") %>
|
||||||
<!--<div class="resource_tip_box fontGrey2">-->
|
<div class="resource_tip_box fontGrey2">
|
||||||
<!--<em></em>-->
|
<em></em>
|
||||||
<!--<span></span>-->
|
<span></span>
|
||||||
<!--<p class="mb5">私有资源:<br/>仅对本项目成员可见</p>-->
|
<p class="mb5">私有资源:<br/>仅对本项目成员可见</p>
|
||||||
<!--<p>公共资源:<br/>对所有用户可见</p>-->
|
<p>公共资源:<br/>对所有用户可见</p>
|
||||||
<!--</div>-->
|
</div>
|
||||||
<%# end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div id="course_list">
|
<div id="course_list">
|
||||||
<%= render :partial => 'project_list',:locals => {project: @project, all_attachments: @all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments} %>
|
<%= render :partial => 'project_list',:locals => {project: @project, all_attachments: @all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments} %>
|
||||||
|
|
|
@ -70,7 +70,11 @@
|
||||||
<% if @course.is_public? %>
|
<% if @course.is_public? %>
|
||||||
<li>
|
<li>
|
||||||
<span id="is_public_<%= file.id %>">
|
<span id="is_public_<%= file.id %>">
|
||||||
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %>
|
<% if params[:tag_name].blank? %>
|
||||||
|
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => file.id, :newtype=>(file.is_public? ? 0:1), :course_id => @course.id), :remote=>true,:class=>"postOptionLink",:method => :post %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => file.id, :newtype=>(file.is_public? ? 0:1), :tag_name => params[:tag_name].force_encoding("UTF-8"), :course_id => @course.id, :other => params[:other]), :remote=>true,:class=>"postOptionLink",:method => :post %>
|
||||||
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<%end%>
|
<%end%>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
共有 <span id="attachment_count"><%= @tip_all_attachments %></span> 个资源
|
共有 <span id="attachment_count"><%= @tip_all_attachments %></span> 个资源
|
||||||
<span id="attachment_count_public" class="fontGrey2 ml10" style="font-weight: normal;">公共资源:<%= @tip_all_public_attachments %>个</span>
|
<span id="attachment_count_public" class="fontGrey2 ml10" style="font-weight: normal;">公共资源:<%= @tip_all_public_attachments %>个</span>
|
||||||
<% if @project %>
|
<% if @project %>
|
||||||
<% if !User.current.member_of?(@project) && params[:tag_name] %>
|
<% if !User.current.member_of?(@project) && params[:tag_name] %>
|
||||||
<span id="attachment_count_private" class="fontGrey2 ml10" style="font-weight: normal;">私有资源:0个</span>
|
<span id="attachment_count_private" class="fontGrey2 ml10" style="font-weight: normal;">私有资源:0个</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
|
@ -9,11 +9,20 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li>
|
<li><%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li>
|
<% if params[:tag_name].blank? %>
|
||||||
|
<li><%= link_to '更新版本',attachments_versions_path(file, :project_id => project.id), :class => "postOptionLink", :remote => true %></li>
|
||||||
|
<% else %>
|
||||||
|
<li><%= link_to '更新版本',attachments_versions_path(file, :tag_name => params[:tag_name].force_encoding("UTF-8"), :project_id => project.id, :other => params[:other]),:class => "postOptionLink",:remote=>true %></li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if project.is_public? %>
|
<% if project.is_public? %>
|
||||||
<li>
|
<li>
|
||||||
<span id="is_public_<%= file.id %>">
|
<span id="is_public_<%= file.id %>">
|
||||||
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => file.id, :newtype=>(file.is_public? ? 0:1)), :remote=>true,:class=>"postOptionLink",:method => :post %>
|
<% if params[:tag_name].blank? %>
|
||||||
|
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => file.id, :newtype=>(file.is_public? ? 0:1), :project_id => project.id), :remote=>true,:class=>"postOptionLink",:method => :post %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => file.id, :newtype=>(file.is_public? ? 0:1), :tag_name => params[:tag_name].force_encoding("UTF-8"), :project_id => project.id, :other => params[:other]), :remote=>true,:class=>"postOptionLink",:method => :post %>
|
||||||
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>");
|
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>");
|
||||||
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||||
|
$("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
|
|
@ -1,8 +1,8 @@
|
||||||
<% if @course %>
|
<% if @course %>
|
||||||
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>");
|
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>");
|
||||||
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||||
<% else %>
|
<% else %>
|
||||||
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/project_file',:locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments}) %>");
|
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/project_file',:locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments}) %>");
|
||||||
// $("#tip_attachment_count").html("<%#= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
|
$("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
|
||||||
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%# course_model %>
|
<%# course_model %>
|
||||||
<% course_file_num = visable_attachemnts_incourse(@course).count%>
|
<%# course_file_num = visable_attachemnts_incourse(@course).count%>
|
||||||
<%# course_file_num = Attachment.where(:container_type => "Course", :container_id => @course.id).count %>
|
<% course_file_num = Attachment.where(:container_type => "Course", :container_id => @course.id).count %>
|
||||||
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
|
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
|
||||||
<% homework_num = visable_course_homework @course %>
|
<% homework_num = visable_course_homework @course %>
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<% project_file_num = Attachment.where(:container_type => "Project", :container_id => @project.id).count %>
|
||||||
<div class="subNav">
|
<div class="subNav">
|
||||||
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
||||||
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
|
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
|
||||||
|
@ -30,8 +31,8 @@
|
||||||
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
|
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
|
||||||
<div class="subNav">
|
<div class="subNav">
|
||||||
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
|
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
|
||||||
<% unless @project.project_score.attach_num == 0 %>
|
<% unless project_file_num == 0 %>
|
||||||
<%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
|
<%= link_to "(#{project_file_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if User.current.member_of?(@project) %>
|
<% if User.current.member_of?(@project) %>
|
||||||
<%#= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
|
<%#= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<% project_file_num = Attachment.where(:container_type => "Project", :container_id => @project.id).count %>
|
||||||
<div class="subNav">
|
<div class="subNav">
|
||||||
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
||||||
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
|
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
|
||||||
|
@ -18,8 +19,8 @@
|
||||||
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
|
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
|
||||||
<div class="subNav">
|
<div class="subNav">
|
||||||
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
|
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
|
||||||
<% unless @project.project_score.attach_num == 0 %>
|
<% unless project_file_num == 0 %>
|
||||||
<%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
|
<%= link_to "(#{project_file_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if User.current.member_of?(@project) %>
|
<% if User.current.member_of?(@project) %>
|
||||||
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml105" %>
|
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml105" %>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<% project_file_num = Attachment.where(:container_type => "Project", :container_id => @project.id).count %>
|
||||||
<div class="subNav">
|
<div class="subNav">
|
||||||
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
||||||
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
|
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
|
||||||
|
@ -29,8 +30,8 @@
|
||||||
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
|
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
|
||||||
<div class="subNav">
|
<div class="subNav">
|
||||||
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
|
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
|
||||||
<% unless @project.project_score.attach_num == 0 %>
|
<% unless project_file_num == 0 %>
|
||||||
<%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
|
<%= link_to "(#{project_file_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if User.current.member_of?(@project) %>
|
<% if User.current.member_of?(@project) %>
|
||||||
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml105" %>
|
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml105" %>
|
||||||
|
|
|
@ -127,7 +127,7 @@
|
||||||
<p class="fontBlue2"><%= @ha["functions"].to_i %></p>
|
<p class="fontBlue2"><%= @ha["functions"].to_i %></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% unless @user_quality_infos.blank? %>
|
<% if !@user_quality_infos.blank? %>
|
||||||
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">贡献统计</span></div>
|
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">贡献统计</span></div>
|
||||||
<div class="analysis-block mt10 f12">
|
<div class="analysis-block mt10 f12">
|
||||||
<ul class="contribute-list">
|
<ul class="contribute-list">
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
|
|
||||||
<% @user_quality_infos.each do |author_info| %>
|
<% @user_quality_infos.each do |author_info| %>
|
||||||
<% user = get_user_by_mail(author_info[:email]) %>
|
<% user = get_user_by_mail(author_info[:email]) %>
|
||||||
<% unless author_info[:changes] == 0 %>
|
<%# unless author_info[:changes] == 0 %>
|
||||||
<ul class="contribute-list">
|
<ul class="contribute-list">
|
||||||
<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">
|
<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">
|
||||||
<div class="mt8">
|
<div class="mt8">
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height"><%= author_info[:ratio] %></li>
|
<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height"><%= author_info[:ratio] %></li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</ul>
|
</ul>
|
||||||
<% end %>
|
<%# end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,8 +3,12 @@
|
||||||
<div class="fl"><h2 class="project_h2_repository"><%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %></h2></div>
|
<div class="fl"><h2 class="project_h2_repository"><%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %></h2></div>
|
||||||
<% unless @entries.nil? %>
|
<% unless @entries.nil? %>
|
||||||
<a href="<%= @zip_path %>" class="btn_zipdown fr" onclick="">ZIP下载</a>
|
<a href="<%= @zip_path %>" class="btn_zipdown fr" onclick="">ZIP下载</a>
|
||||||
<% if quality_analysis(User.current.try(:login), @repository.id).nil? && User.current.member_of?(@project) && @project.is_public? %>
|
<% if User.current.member_of?(@project) && @project.is_public? %>
|
||||||
<%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch ), :remote => true, :class => "btn_zipdown fr" %>
|
<% if quality_analysis(User.current.try(:login), @repository.id).nil? %>
|
||||||
|
<%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "1"), :remote => true, :class => "btn_zipdown fr" %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to "重新分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "2"), :remote => true, :class => "btn_zipdown fr" %>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!--quality_analysis-->
|
<!--quality_analysis-->
|
||||||
|
|
Loading…
Reference in New Issue