Merge branch 'rep_quality' into develop

This commit is contained in:
huang 2016-08-13 15:37:36 +08:00
commit 10730f3fba
46 changed files with 3444 additions and 2884 deletions

View File

@ -53,7 +53,7 @@ class AppliedProjectController < ApplicationController
else
@project = Project.find(params[:project_id])
end
if !@project || params[:invite_code].upcase.to_s != @project.invite_code
if !@project || params[:invite_code].strip.upcase.to_s != @project.invite_code
@flag = 1
elsif User.current.member_of?(@project)
@flag = 2

View File

@ -77,19 +77,25 @@ class FilesController < ApplicationController
if params[:insite]
if q == "%%"
@result = []
@searched_attach = paginateHelper @result,10
# @searched_attach = paginateHelper @result,10
else
@result = find_public_attache q,sort
@result = visable_attachemnts_insite @result,@course
@searched_attach = paginateHelper @result,10
# @searched_attach = paginateHelper @result,10
end
else
@result = find_course_attache q,@course,sort
@result = visable_attachemnts @result
@searched_attach = paginateHelper @result,10
# @searched_attach = paginateHelper @result,10
@tag_list = get_course_tag_list @course
end
@all_attachments = @result
@limit = 10
@feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@obj_attachments = paginateHelper @all_attachments,10
#rescue Exception => e
# #render 'stores'
# redirect_to search_course_files_url
@ -144,18 +150,26 @@ class FilesController < ApplicationController
if params[:insite]
if q == "%%"
@project_attachment_result = []
@searched_attach = paginateHelper @project_attachment_result, 10
# @searched_attach = paginateHelper @project_attachment_result, 10
else
@project_attachment_result = find_public_attache q,sort
@project_attachment_result = visable_attachemnts_insite @project_attachment_result, @project
@searched_attach = paginateHelper @project_attachment_result, 10
# @searched_attach = paginateHelper @project_attachment_result, 10
end
else
@project_attachment_result = find_project_attache q, @project,sort
@project_attachment_result = visable_attachemnts @project_attachment_result
@searched_attach = paginateHelper @project_attachment_result,10
# @searched_attach = paginateHelper @project_attachment_result,10
@tag_list = get_project_tag_list @project
end
@all_attachments = @project_attachment_result
@limit = 10
@feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@obj_attachments = paginateHelper @all_attachments,10
#rescue Exception => e
# #render 'stores'
# redirect_to search_course_files_url
@ -867,7 +881,17 @@ class FilesController < ApplicationController
else
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
end
@searched_attach = paginateHelper @result,10
@all_attachments = @result
@limit = 10
@feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@obj_attachments = paginateHelper @all_attachments,10
# @searched_attach = paginateHelper @result,10
if @project
@tag_list = get_project_tag_list @project
@result_search_project = @result

View File

@ -1,7 +1,8 @@
class PullRequestsController < ApplicationController
before_filter :find_project_and_repository
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new]
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new,
:update_pull_request, :pull_request_comments, :create_pull_request_comment]
layout "base_projects"
include PullRequestsHelper
include ApplicationHelper
@ -14,9 +15,19 @@ class PullRequestsController < ApplicationController
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "opened" || request.state == "reopened"}
when "2"
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}
when "3"
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"}
end
@requests_opened_count = @requests.count
@requests_merged_count = params[:type] ? @requests.count : @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count
@requests_merged_count = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count
@requests_closed_count = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"}.count
@limit = 10
@is_remote = true
@count = type_count(type, @requests_opened_count, @requests_merged_count, @requests_closed_count)
@pages = Paginator.new @count, @limit, params['page'] || 1
@offset ||= @pages.offset
@requests = paginateHelper @requests, 10
respond_to do |format|
format.html
format.js
@ -84,6 +95,15 @@ class PullRequestsController < ApplicationController
@commits_count = @commits.count
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@changes_count = @changes.count
@comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse
@comments_count = @comments.count
@limit = 10
@is_remote = true
@count = @comments_count
@pages = Paginator.new @count, @limit, params['page'] || 1
@offset ||= @pages.offset
@comments = paginateHelper @comments, 10
end
# Accept a merge request.
@ -99,6 +119,7 @@ class PullRequestsController < ApplicationController
def accept_pull_request
begin
status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
PullRequest.create(:pull_request_id => status.id, :user_id => User.current.id, :gpid => status.project_id)
respond_to do |format|
format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)}
end
@ -107,16 +128,110 @@ class PullRequestsController < ApplicationController
end
end
# 获取某次请求的提交次数
def pull_request_commits
@type = parms[:type]
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
# Updates a merge request.
#
# @example
# Gitlab.update_merge_request(5, 42, :title => 'New title')
#
# @param [Integer] project The ID of a project.
# @param [Integer] id The ID of a merge request.
# @param [Hash] options A customizable set of options.
# @option options [String] :title The title of a merge request.
# @option options [String] :source_branch The source branch name.
# @option options [String] :target_branch The target branch name.
# @option options [Integer] :assignee_id The ID of a user to assign merge request.
# @option options [String] :state_event New state (close|reopen|merge).
# @return [Gitlab::ObjectifiedHash] Information about updated merge request.
def update_pull_request
begin
@g.update_merge_request(@project.gpid, params[:id], :state_event => params[:state])
respond_to do |format|
format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)}
end
rescue Exception => e
@message = e.message
end
end
# 获取某次请求的改动
# Creates a merge request.
#
# @example
# Gitlab.create_merge_request(5, 'New merge request',
# :source_branch => 'source_branch', :target_branch => 'target_branch')
# Gitlab.create_merge_request(5, 'New merge request',
# :source_branch => 'source_branch', :target_branch => 'target_branch', :assignee_id => 42)
def create_pull_request_comment
content = params[:pull_request_comment]
begin
@comments = @g.create_merge_request_comment(@project.gpid, params[:id], content, User.current.gid)
respond_to do |format|
format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)}
end
rescue Exception => e
@message = e.message
end
end
# Gets the comments on a merge request.
#
# @example
# Gitlab.merge_request_comments(5, 1)
def pull_request_comments
begin
@comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse
@comments_count = @comments.count
@limit = 10
@is_remote = true
@count = @comments_count
@pages = Paginator.new @count, @limit, params['page'] || 1
@offset ||= @pages.offset
@comments = paginateHelper @comments, 10
rescue Exception => e
@message = e.message
end
end
# Get a list of merge request commits.
# Parameters:
# id (required) - The ID of a project
# merge_request_id (required) - The ID of MR
def pull_request_commits
begin
@type = params[:type]
@commits = @g.merge_request_commits(@project.gpid, params[:id])
@commits_count = @commits.count
@limit = 10
@is_remote = true
@count = @commits_count
@pages = Paginator.new @count, @limit, params['page'] || 1
@offset ||= @pages.offset
@commits = paginateHelper @commits, 10
rescue Exception => e
@message = e.message
end
end
# Shows information about the merge request including its files and changes. With GitLab 8.2 the return fields upvotes and downvotes are deprecated and always return 0.
# Parameters:
# id (required) - The ID of a project
# merge_request_id (required) - The ID of MR
def pull_request_changes
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@changes_count = @changes.count
begin
@type = params[:type]
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@changes_count = @changes.count
@limit = 10
@is_remote = true
@count = @changes_count
@pages = Paginator.new @count, @limit, params['page'] || 1
@offset ||= @pages.offset
@changes = paginateHelper @changes, 10
rescue Exception => e
@message = e.message
end
end
private

View File

@ -17,6 +17,7 @@ class QualityAnalysisController < ApplicationController
# params 说明:{identifier版本库名}
def create
logger.info("11111111111111111111111111111")
begin
user_name = User.find(params[:user_id]).try(:login)
identifier = params[:identifier]
@ -32,12 +33,18 @@ class QualityAnalysisController < ApplicationController
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"]
quality_an = QualityAnalysis.where(:sonar_name => sonar_name).first
if @client.job.exists?(job_name) && QualityAnalysis.where(:sonar_name => sonar_name).select{|qa| arr.include?(qa.sonar_name)}.blank?
aa = @client.job.delete("#{job_name}")
logger.info("###########################6666666666666")
logger.info("job_name is ###########################{job_name}")
logger.info("@client_jenkins is ###########################{@client_jenkins}")
logger.info("@client_jenkins job is ###########################{@client_jenkins.job}")
logger.info("@client_jenkins result is ###########################{@client_jenkins.job.exists?(job_name)}")
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}")
quality_an.delete unless quality_an.blank?
end
# Checks if the given job exists in Jenkins.
# unless @client.job.exists?(job_name)
unless @client_jenkins.job.exists?(job_name)
@g = Gitlab.client
branch = params[:branch]
language = swith_language_type(params[:language])
@ -59,20 +66,20 @@ class QualityAnalysisController < ApplicationController
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties
# jenkins job创建
jenkins_job = @client.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
@g.add_project_hook(@project.gpid, @jenkins_address + "/project/#{job_name}")
# job创建完成后自动运行job,如果运行成功则返回200
code = @client.job.build("#{job_name}")
code = @client_jenkins.job.build("#{job_name}")
logger.error("build result ==> #{code}")
# 判断调用sonar分析是否成功
# 等待启动时间处理, 最长时间为30分钟
for i in 0..360 do
sleep(5)
@current_build_status = @client.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")
break
if i == 360
@ -86,7 +93,7 @@ class QualityAnalysisController < ApplicationController
sleep(10)
# 获取sonar output结果
console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["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
@ -94,14 +101,14 @@ class QualityAnalysisController < ApplicationController
# 2/creat和build成功调用sonar启动失败则删除job
# 错误信息存储需存到Trustie数据库否则一旦job删除则无法获取这些信息
if jenkins_job == '200' && code != '201'
@client.job.delete("#{job_name}")
@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.job.delete("#{job_name}")
@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,
@ -111,17 +118,24 @@ class QualityAnalysisController < ApplicationController
end
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
rescue => e
@message = e.message
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)}
logger.error("######################====>#{e.message}")
respond_to do |format|
format.html{redirect_to error_list_project_quality_analysi_path(:project_id => @project.id, :job_name => job_name, :message => @message)}
# format.html{redirect_to :controller => 'repositories', :action => 'show', :id => @project, :repository_id => identifier}
end
end
end
def error_list
@ -159,9 +173,9 @@ class QualityAnalysisController < ApplicationController
rep_id = Repository.where(:project_id => @project.id, :identifier => qa.rep_identifier).first.try(:id)
job_name = "#{qa.author_login}-#{rep_id}"
logger.info("result: job_name ###################==>#{job_name}")
logger.info("result: @client.job ###################==>#{@client.job}")
logger.info("result: @client_jenkins.job ###################==>#{@client_jenkins.job}")
d_job = @client.job.delete(job_name)
d_job = @client_jenkins.job.delete(job_name)
logger.info("result: delete job ###################==>#{d_job}")
qa.delete
respond_to do |format|
@ -198,7 +212,7 @@ class QualityAnalysisController < ApplicationController
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties
# update成功则返回 200
jenkins_job = @client.job.update("#{job_name}", @doc.to_xml)
jenkins_job = @client_jenkins.job.update("#{job_name}", @doc.to_xml)
# 数据更新到Trustie数据
if jenkins_job == '200'
logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}")
@ -278,9 +292,10 @@ class QualityAnalysisController < ApplicationController
@jenkins_address = Redmine::Configuration['jenkins_address']
jenkins_username = Redmine::Configuration['jenkins_username']
jenkins_password = Redmine::Configuration['jenkins_password']
logger.info("22222222222222222222222222222222")
# connect jenkins
@client = 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
logger.error("failed to connect Jenkins ==> #{e}")
end

View File

@ -42,7 +42,7 @@ class UsersController < ApplicationController
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list,
:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks]
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@ -3418,7 +3418,22 @@ class UsersController < ApplicationController
end
def user_projectlist
@order, @c_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
@order, @c_sort, @type, @list_type = 1, 2, 1, 1
#limit = 5
@my_projects = @user.projects.visible.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
@my_projects_count = @my_projects.count
@my_joined_projects = @user.projects.visible.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
@my_joined_projects_count = @my_joined_projects.count
respond_to do |format|
format.html {render :layout => 'new_base_user'}
end
end
def sort_project_list
@order, @c_sort, @type, @list_type = params[:order] || 1, params[:sort] || 1, params[:type] || 1, params[:list_type] || 1
#limit = 5
#确定 sort_type
if @order.to_i == @type.to_i
@ -3427,11 +3442,16 @@ class UsersController < ApplicationController
@c_sort = 2
end
sort_name = "updated_at"
sort_name = "updatetime"
sort_type = @c_sort == 1 ? "asc" : "desc"
#@projects = @user.projects.visible.order("#{sort_name} #{sort_type}")
@projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS #{sort_name} ").order("#{sort_name} #{sort_type}")
if @list_type.to_i == 1
@projects = @user.projects.visible.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS #{sort_name}").order("#{sort_name} #{sort_type}")
else
@projects = @user.projects.visible.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS #{sort_name}").order("#{sort_name} #{sort_type}")
end
@projects_count = @projects.count
#根据 问题+资源数排序 @project.project_score.issue_num @project.project_score.attach_num
if @order.to_i == 2
@ -3448,18 +3468,8 @@ class UsersController < ApplicationController
@type = 1
end
#分页
@limit = 10
@is_remote = true
@atta_count = @projects.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
@projects = paginateHelper @projects,@limit
@is_project = 1
respond_to do |format|
format.js
format.html {render :layout => 'new_base_user'}
end
end

View File

@ -14,4 +14,37 @@ module PullRequestsHelper
User.find(user_id).try(:login)
end
# 获取接受PullRequest用户的信息
def accept_user pull_request_id
PullRequest.where(:pull_request_id => pull_request_id).first
end
def get_state state
case state
when "open","reopened"
l(:label_state_open)
when "closed"
l(:label_state_closed)
when "merged"
l(:label_state_merged)
end
end
def type_count type, requests_opened_count, requests_merged_count, requests_closed_count
case type
when nil, "1"
requests_opened_count
when "2"
requests_merged_count
when "3"
requests_closed_count
end
end
# 判断是否允许创建Pull Request
# 如果分支相同,并且项目相同则提示
def judge_pr_allow
end
end

View File

@ -6,18 +6,23 @@ module QualityAnalysisHelper
if val <= 5
arr << "很好"
arr << "b_green2"
arr << "A"
elsif val. > 5 && val <= 10
arr << "较好"
arr << "b_slow_yellow"
arr << "B"
elsif val > 10 && val <= 20
arr << "中等"
arr << "b_yellow"
arr << "C"
elsif val > 20 && val <= 50
arr << "较差"
arr << "b_slow_red"
arr << "D"
elsif val > 20
arr << "很差"
arr << "b_red"
arr << "E"
end
end

View File

@ -47,9 +47,9 @@ module RepositoriesHelper
end
# 获取文件目录的最新动态
def get_trees_last_changes(project_id, rev, ent_name, g)
def get_trees_last_changes(gpid, rev, ent_name, g)
begin
tree_changes = g.rep_last_changes(project_id, :rev => rev, :path => ent_name)
tree_changes = g.rep_last_changes(gpid, :rev => rev, :path => ent_name)
rescue Exception => e
puts e
end

View File

@ -1254,12 +1254,14 @@ class Project < ActiveRecord::Base
def create_project_ealasticsearch_index
return if Rails.env.development?
if self.is_public
self.__elasticsearch__.index_document
end
end
def update_project_ealasticsearch_index
return if Rails.env.development?
if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
begin
self.__elasticsearch__.update_document
@ -1276,6 +1278,7 @@ class Project < ActiveRecord::Base
end
def delete_project_ealasticsearch_index
return if Rails.env.development?
begin
self.__elasticsearch__.delete_document
rescue => e

View File

@ -0,0 +1,4 @@
class PullRequest < ActiveRecord::Base
attr_accessible :gpid, :pull_request_id, :user_id
validates_uniqueness_of :pull_request_id
end

View File

@ -1,19 +1,14 @@
<% curse_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
<% curse_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
<div id="resource_detail_<%=file.id %>">
<%=render :partial=>'files/resource_detail',:locals => {:file => file} %>
<%=render :partial=>'files/resource_detail',:locals => {:file => file} %>
</div>
<% else %>
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
<% end %>
<% end %>
<% if curse_attachments.count == 10%>
<% if params[:action] == 'search' %>
<%=link_to "点击展开更多", search_course_files_path({:course_id => course.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<% else %>
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
<%=link_to "点击展开更多", course_files_path(:course_id => course.id, :page => @page), :id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<%end%>
<% end%>
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
<% end %>
<% end %>
<ul class="wlist">
<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%>
</ul>

View File

@ -66,17 +66,10 @@
<% end %>
<% end %>
<% if project_attachments.count == 10%>
<% if params[:action] == 'search_project' %>
<!--<ul class="wlist">-->
<!--<%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>-->
<!--</ul>-->
<%=link_to "点击展开更多", search_project_project_files_path({:project_id => project.id, :page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<%else%>
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
<%=link_to "点击展开更多", project_files_path(:project_id => project.id,:page => @page),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<%end%>
<% end%>
<ul class="wlist">
<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%>
</ul>

View File

@ -1,7 +1,9 @@
<% if @course %>
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/course_list',: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 %>');
<% elsif @project %>
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/project_list', :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}) %>");
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
<% elsif @org_subfield %>
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/org_subfield_list', :locals => {org_subfield:@org_subfield, all_attachments:@all_attachments, sort:@sort, order:@order, org_subfield_attachments:@obj_attachments})%>");
<%end %>

View File

@ -1,6 +1,3 @@
<% if (@obj_pages &&( @obj_pages.page > 1)) || (@feedback_pages && (@feedback_pages.page > 1)) %> //搜索的时候有时候是需要加载下一页,有时候是直接替换当前 #course_list。这个根据 page来判定
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach} )%>");
<% else %>
$("#course_list").html("<%= escape_javascript(render :partial => 'files/course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
$("#attachment_count").html("<%= @result.count%>")
<% end %>
$("#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 %>');

View File

@ -1,7 +1,2 @@
<% if (@obj_pages &&( @obj_pages.page > 1)) || (@feedback_pages && (@feedback_pages.page > 1)) %> //搜索的时候有时候是需要加载下一页,有时候是直接替换当前 #course_list。这个根据 page来判定
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/project_list',
:locals => {project: @project, all_attachments:@result, sort:@sort, order:@order, project_attachments:@searched_attach})%>");
<% else %>
$("#course_list").html("<%= escape_javascript(render :partial => 'files/project_list',:locals => {project:@project, all_attachments:@result, sort:@sort, order:@order,project_attachments:@searched_attach})%>");
$("#attachment_count").html("<%= @project_attachment_result.count %>")
<% end %>
$("#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}) %>");
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');

View File

@ -1,8 +1,7 @@
<% if @course %>
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
$("#course_filter_order").html("<%= escape_javascript(render :partial => 'course_file_filter_order', :locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach, tag_name: @tag_name, q: @q})%>");
$("#attachment_count").html("<%= @result.count%>")
$("#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 %>');
<% else %>
$("#course_list").html("<%= escape_javascript(render :partial => 'project_list',:locals => {project:@project, all_attachments:@result_search_project, sort:@sort, order:@order, project_attachments:@searched_attach}) %>");
$("#attachment_count").html("<%= @result_search_project.count%>")
$("#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}) %>");
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
<% end %>

View File

@ -11,7 +11,7 @@
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label><span class="c_red">*</span>&nbsp;<%= l(:label_projects_new_name)%>&nbsp;&nbsp;</label>
<input type="text" name="project[name]" id="project_name" class="courses_input" maxlength="100" onkeyup="regex_project_name();">
<input type="text" name="project[name]" id="project_name" class="courses_input" maxlength="100" placeholder="例如:团队协作方法与机制研究" onkeyup="regex_project_name();">
<span class="c_red" id="project_name_notice" style="display: none;">项目名称不能为空</span>
</li>
<div class="cl"></div>

View File

@ -15,9 +15,9 @@
<% if @forked_project.nil? %>
<%= select_tag :branch, options_for_select(@source_rev), :id => "pull_request_branch", :name => "target_branch", :value => "target_branch",:class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;" %>
<% else %>
<select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" name="source_project" value="source_project" class="ml30 fontGrey3 fb fl" style = "padding:5px 0 5px 5px;">
<option value="source_project_name"><%= @source_project_name %></option>
<option value="forked_project_name"><%= @forked_project_name %></option>
<select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" id="pull_request_project" name="source_project" value="source_project" class="ml30 fontGrey3 fb fl" style = "padding:5px 0 5px 5px;">
<option name="<%= @project.id %>" value="source_project_name" ><%= @source_project_name %></option>
<option name="<%= @forked_project.id %>" value="forked_project_name" ><%= @forked_project_name %></option>
</select>
<select name="target_branch" id="pull_request_branch" class = "ml30 fontGrey3 fb fl" style = "width:140px; padding:5px 0 5px 5px;">
<% @source_rev.each do |rev| %>
@ -25,8 +25,9 @@
<% end %>
</select>
<% end %>
<p id="pull_request_project_hidden" style="display: none"><%= @forked_project.nil? ? "" : @project.id %></p>
<div class="cl"></div>
<p id ="pull_request_branch_error" class="ml100 fontGrey2 mt5 c_red" style="display: none">同一个项目的源分支和目标分支不能相同</p>
<p id ="pull_request_branch_error" class="ml100 fontGrey2 mt5 c_red" style="display: none">没有内容可以合并,请切换一个不同的分支</p>
<div class="cl"></div>
</div>
<div class="new-merge-row b_grey" style="border-top:1px solid #ddd;">
@ -56,7 +57,9 @@
{
var source_branch = $.trim($("#source_branch").val());
var target_branch = $.trim($("#pull_request_branch").val());
if(source_branch == target_branch)
var target_project = $.trim($("#pull_request_project").children().attr("name"));
var target_forked_project = $.trim($("#pull_request_project_hidden").text());
if(target_project == target_forked_project && source_branch == target_branch)
{
$("#pull_request_branch_error").show();
return false;
@ -71,7 +74,7 @@
//提交pull request
function pull_request_commit()
{
if(regex_pr_name())
if(regex_pr_name() && regex_branch())
{
$("#pull_request_form").submit();
}

View File

@ -1,4 +1,4 @@
<% unless @changes.blank? %>
<% if !@changes.blank? && @type == "3" %>
<% @changes.each do |cd| %>
<div class="showing-changes-row fontGrey2" style="width:710px;">
<a class="linkGrey3" id="changed-files">
@ -29,5 +29,13 @@
</table>
</div>
<% end %>
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul>
<div class="cl"></div>
</div>
</div>
<% end %>

View File

@ -0,0 +1,49 @@
<div class="merge-discussion-input">
<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create_pull_request_comment', :project_id => @project.id), :id => 'pull_request_comment_form', :method => "post", :remote => true) do %>
<textarea id="pull_request_comment" name="pull_request_comment"></textarea>
<span id ="pr_comment_tip" class="fontGrey2 c_red" style="display: none">内容不能为空</span>
<a href="javascript:void(0);" class="BlueCirBtn mt10" onclick="pull_request_commit()">提交请求</a>
<% end %>
</div>
<% @comments.each do |comment| %>
<div class="merge-discussion-content merge-discussion-automatic">
<%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "link-blue mr15 fl" %>
<span class="fl fontGrey2"><%= time_tag(comment.created_at) %>前</span>
<div class="cl"></div>
<div class="merge-discussion-detail"><%= comment.note %></div>
</div>
<% end %>
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul>
<div class="cl"></div>
</div>
</div>
<script>
function regex_pr_comment()
{
var comment = $.trim($("#pull_request_comment").val());
if(comment.length == 0)
{
$("#pr_comment_tip").show();
return false;
}
else
{
$("#pr_comment_tip").hide();
return true;
}
}
//提交pull request_comment
function pull_request_commit()
{
if(regex_pr_comment())
{
$("#pull_request_comment_form").submit();
}
}
</script>

View File

@ -1,19 +1,32 @@
<% @commits.each do |commit| %>
<div class="new-merge-wrap">
<div class="merge-commit-time">
<img width="16" class="ui-datepicker-trigger mr15" style="cursor:default; margin-top:3px; margin-left:0;" /><span class="fontGrey3"><%= format_date(commit.created_at) %></span>
<!--<p class="mt10 fontGrey2">1次提交</p>-->
<p class="mt10 fontGrey2"><%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %>创建于<%= time_tag(commit.created_at) %>前</p>
</div>
<div class="merge-commit-detail">
<span class="fontGrey3 fb"><%= commit.title %></span>
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<% if !@commits.blank? && @type == "2" %>
<% @commits.each do |commit| %>
<div class="new-merge-wrap">
<div class="merge-commit-time">
<img width="16" class="ui-datepicker-trigger mr15" style="cursor:default; margin-top:3px; margin-left:0;" /><span class="fontGrey3"><%= format_date(commit.created_at) %></span>
<!--<p class="mt10 fontGrey2">1次提交</p>-->
<p class="mt10 fontGrey2"><%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %> 创建于<%= time_tag(commit.created_at) %>前</p>
</div>
<div class="merge-commit-detail">
<span class="fontGrey3 fb"><%= commit.title %></span>
</div>
<div class="merge-commit-code">
</div>
<div class="merge-commit-code">
<span class="fontGrey3">
<%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %>
</span>
</div>
<div class="cl"></div>
</div>
<% end %>
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul>
<div class="cl"></div>
</div>
</div>
<div class="cl"></div>
</div>
<% end %>

View File

@ -4,7 +4,7 @@
<% @requests.each do |request| %>
<li>
<% request %>
<%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl"%>
<%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl hidden", :style => "width:100%;"%>
<!--<a href="javascript:void(0);" class="fr fontGrey2 fb"><img src="/images/comments.png" class="mr5" width="15" />0</a><span class="fr mr15 fb fontGrey2">关闭</span>-->
<div class="cl mb5"></div>
<span class="fontGrey2">由 <%= link_to request.author.try(:username), user_path(get_user_by_login_and(request.author.try(:username))), :class => "link-blue" %> 创建于<%= time_tag(request.created_at) %></span>
@ -12,4 +12,13 @@
<div class="cl"></div>
</li>
<% end %>
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul>
<div class="cl"></div>
</div>
</div>
<% end %>

View File

@ -4,14 +4,17 @@
<div id="pull_request_show">
<div id="mergeShow" class="f14 fontGrey2 merge-show">
<span class="mr10 open-status"><%= @request.state == "merged" ? "已合并" : "待处理" %></span><span class="mr10">合并请求</span> 由<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %>提交 · 最后编辑时间<%= time_tag(@request.updated_at) %>
<!--<a href="javascript:void(0);" class="BlueCirBtnMini fr mt5">编辑</a>-->
<span class="mr10 open-status"><%= get_state(@request.state) %></span><span class="mr10">合并请求</span> 由 <%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %> 于 <%= time_tag(@request.created_at) %> 前提交 · 最后编辑时间 <%= time_tag(@request.updated_at) %> 前
<% unless @request.state == "merged" %>
<%= link_to "#{@request.state == 'closed' ? '重新打开' : '关闭'}", update_pull_request_project_pull_request_path(@request.id, :project_id => @project.id, :state => @request.state =="closed" ? "reopen" : "close"), :class => "BlueCirBtn fr" %>
<% end %>
<div class="cl"></div>
</div>
<div class="new-merge-row b_grey"><strong><%= @request.title %></strong><p class="mt10"><%= @request.description %></p></div>
<div class="mt10 mb15">
请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span>
<div class="mt10 mb15">
<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>
请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span>
<% if @commits_count == 0 && @changes_count == 0 %>
<div class="merge-commit-option mt15">
<span class="fontGrey3 fb" style="font-size:13px;"><img src="/images/warning.png" width="16" class="mr5 mt2 fl"><%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %></span><br />
@ -21,8 +24,11 @@
<% else %>
<% if @request.state == "merged" %>
<div class="merge-commit-option mt15">
<span class="fontGrey3 fb" style="font-size:13px;"><%#= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %> 前合并</span><br />
<p class="fontGrey2 mt5">改动已合并至<%= @request.target_branch %></p>
<% if accept_user(@request.id).blank? %>
<p class="fontGrey2 mt5">改动已合并至<%= @request.target_branch %></p>
<% else %>
<span class="fontGrey3 fb" style="font-size:13px;"><%= link_to User.find(accept_user(@request.id).user_id), user_path(accept_user(@request.id).user_id), :class => "link-blue" %> 于 <%= time_tag(accept_user(@request.id).created_at) %> 前合并</span><br />
<% end %>
</div>
<% else %>
<% if is_project_manager?(User.current.id, @project.id) %>
@ -31,19 +37,25 @@
</div>
<% end %>
<% end %>
</div>
<ul class="merge-record" style="border-top:1px solid #ddd;">
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %></li>
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li>
<li><%= link_to "留言<span class='project-number-dot'>#{@comments_count}</span>".html_safe, pull_request_comments_project_pull_request_path(@request.id, :project_id => @project.id, :type => "1"), :remote => true, :class => "active" %></li>
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => "2"), :remote => true %></li>
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => "3"), :remote => true %></li>
</ul>
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<div id="merge_record_0">
<% if @type == nil || @type == "1" %>
<div id="merge_record_0">
<%= render :partial => "pull_requests/pull_request_comments" %>
</div>
<% end %>
<div id="merge_record_1" class="undis">
<%= render :partial => "pull_requests/pull_request_commits" %>
</div>
<div id="merge_record_1" class="undis">
<div id="merge_record_2" class="undis">
<%= render :partial => "pull_requests/pull_request_changes" %>
</div>
<% end %>
</div>
@ -51,19 +63,13 @@
<script>
$("#pull_request_show").parent().css("width","730px");
$("#changed-files").toggle(function(){
$("#changed-files-detail").show();
},function(){
$("#changed-files-detail").hide();
});
$(".merge-record li a").click(function(){
$(".merge-record li a").removeClass("active");
$(this).addClass("active");
var index = $(".merge-record li a").index(this);
$("#merge_record_0, #merge_record_1").hide();
$("#merge_record_0, #merge_record_1, #merge_record_2").hide();
$("#merge_record_" + index).show();
});
</script>

View File

@ -2,6 +2,7 @@
<ul id="mergeBanner" class="project-merge-banner">
<li class="active"><%= link_to "待处理<span class='project-number-dot'>#{@requests_opened_count}</span>".html_safe, project_pull_requests_path(:type => "1"), :remote => true %></li>
<li><%= link_to "已处理<span class='project-number-dot'>#{@requests_merged_count}</span>".html_safe, project_pull_requests_path(:type => "2"), :remote => true %></li>
<li><%= link_to "已关闭<span class='project-number-dot'>#{@requests_closed_count}</span>".html_safe, project_pull_requests_path(:type => "3"), :remote => true %></li>
<%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
<div class="cl"></div>
@ -12,6 +13,7 @@
<%= render "pull_requests/pull_requests_list" %>
</ul>
<script>
$("#mergeBanner").parent().css("width","730px");

View File

@ -1 +1 @@
$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>');
$("#merge_record_2").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes") %>');

View File

@ -0,0 +1 @@
$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_comments") %>');

View File

@ -1 +1 @@
$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits", :locals => {:type => @type} ) %>');
$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits") %>');

View File

@ -10,22 +10,23 @@
<li class="analysis-result-version fl fontBlue2" >分支</li>
<li class="analysis-result-loc fl fontBlue2" >语言</li>
<li class="analysis-result-debt fl fontBlue2" >路径</li>
<li class="analysis-result-time fl fontBlue2" ></li>
<!--<li class="analysis-result-time fl fontBlue2" >bianji</li>-->
<li class="analysis-result-time fl fontBlue2" >最近更新</li>
<li class="analysis-result-edit fl fontBlue2" ></li>
<div class="cl"></div>
</ul>
<% if @quality_analyses.count >0 %>
<% @quality_analyses.each do |qa| %>
<ul class="analysis-result-list">
<li title="Name" title="名称"><%=link_to "#{qa.author_login}:#{qa.rep_identifier}", project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %></li>
<li class="analysis-result-version fl fontBlue2 hidden" title="分支名"><%= qa.branch %></li>
<li class="analysis-result-loc fl fontBlue2 hidden" title="语言"><%= qa.language %></li>
<li class="analysis-result-debt fl fontBlue2 hidden" title="路径"><%= qa.path %></li>
<li title="<%= qa.author_login+ ':' +qa.rep_identifier %>"><%=link_to "#{qa.author_login}:#{qa.rep_identifier}", project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %></li>
<li class="analysis-result-version fl fontBlue2 hidden" title="<%= qa.branch %>"><%= qa.branch %></li>
<li class="analysis-result-loc fl fontBlue2 hidden" title="<%= qa.language %>"><%= qa.language %></li>
<li class="analysis-result-debt fl fontBlue2 hidden" title="<%= qa.path %>"><%= qa.path %></li>
<li class="analysis-result-time fl fontBlue2 hidden" title="<%= qa.updated_at %>"><%= format_time(qa.updated_at) %></li>
<% if User.current.try(:login) == qa.author_login || User.current.admin? || is_project_manager?(User.current.id, @project.id) %>
<li class="analysis-result-time fl" title="编辑">
<li class="analysis-result-edit fl fontBlue2 hidden" title="<%= qa.path %>">
<%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true, :class => "fontBlue2" %><span style="color: #888"> / </span>
<%=link_to "删除", delete_project_quality_analysi_path(qa, :project_id => @project.id), :method => "delete", :confirm => "删除会一并删除分析结果,确定删除吗?", :class => "fontBlue2" %>
</li>
</li>
<% end %>
<div class="cl"></div>
</ul>

View File

@ -12,7 +12,7 @@
<div class="analysis-genral">
<p id="container_sqale_rating" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">质量等级</p>
<p class="fontBlue2 pr"><%= @ha["sqale_rating"] %>
<p class="fontBlue2 pr"><%= sqale_rating_status(@ha["sqale_rating"].to_i)[2] %>
<span class="f10 c_white analysis-genral-icon <%= sqale_rating_status(@ha["sqale_rating"].to_i)[1] %> borderRadius">
<%= @ha["sqale_rating"].nil? ? "很好" : sqale_rating_status(@ha["sqale_rating"].to_i)[0] %>
</span>

View File

@ -5,6 +5,8 @@
<div class="c_red">本次分析失败,原因如下:</div>
<% if @build_console_result == false %>
分析超时
<% elsif params[:message] %>
<%= params[:message] %>
<% else %>
<%= h @error_list.try(:output).html_safe %>
<% end %>

View File

@ -26,19 +26,19 @@
</td>
<div id="children_tree">
<td class="tree-comments c_grey hidden">
<div class="hidden" title="<%= (latest_changes.message) if latest_changes && latest_changes.message %>">
<%= (latest_changes.message) if latest_changes && latest_changes.message %>
<div class="hidden" title="<%= (latest_changes.message) if latest_changes %>">
<%= (latest_changes.message) if latest_changes %>
</div>
</td>
<td class="tree-author c_grey">
<div class="hidden" title="<%= (latest_changes.author) if latest_changes && latest_changes.author %>">
<%= (latest_changes.author) if latest_changes && latest_changes.author %>
<div class="hidden" title="<%= (latest_changes.author_name) if latest_changes %>">
<%= (latest_changes.author_name) if latest_changes %>
</div>
</td>
<td class="tree-age c_grey">
<div class="hidden" title="<%= format_time(latest_changes.time) %>">
<div class="hidden" title="<%= format_time(latest_changes.time) if latest_changes %>">
<%# 为了转换UTC时间时差8小时 %>
<%= distance_of_time_in_words(latest_changes.time, Time.now + 8.hours) if latest_changes && latest_changes.time %>
<%= distance_of_time_in_words(latest_changes.time, Time.now) if latest_changes %>
</div>
</td>
</div>

View File

@ -0,0 +1,3 @@
<div id="user_join_projects_list">
<%= render :partial => 'users/project_list', :locals => {:projects => @my_joined_projects, :list_type => 2, :count => @my_joined_projects_count}%>
</div>

View File

@ -0,0 +1,3 @@
<div id="user_projects_list">
<%= render :partial => 'users/project_list', :locals => {:projects => @my_projects, :list_type => 1, :count => @my_projects_count}%>
</div>

View File

@ -0,0 +1,63 @@
<div class="syllabus_category">
<% unless projects.empty? %>
<% if @type.to_i == 2 %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :style => "margin-right: 5px;", :remote => true %>
<% else %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortdownbtn sort_no fr", :style => "margin-right: 5px;", :remote => true %>
<% end %>
<%= link_to "人气", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortTxt fr", :remote => true %>
<% if @type.to_i == 1 %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :remote => true %>
<% else %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortdownbtn sort_no fr", :remote => true %>
<% end %>
<%= link_to "时间", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortTxt fr", :remote => true %>
<% end %>
<span class="grayTxt fl "><%=@user == User.current ? "我" : "他" %><%= list_type == 1 ? "创建" : "参与"%>的项目</span>
<div class="cl"></div>
</div>
<div class="syllabus_courses_box" id="project_li_<%=list_type %>">
<% if projects.empty? %>
<div class="icons_tishi"><img src="/images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
<% if list_type == 1 %>
<p class="sy_tab_con_p"><%=@user == User.current ? "您" : "他" %>还没有创建项目~~<br />
<%= link_to "创建项目", new_project_path(:host=> Setting.host_name), :target => "_blank", :class => "sy_btn_green ml5 mt5" if @user == User.current %>
</p>
<% else %>
<p class="sy_tab_con_p"><%=@user == User.current ? "您" : "他" %>还没有加入项目~~<br />
<%= link_to "加入项目", applied_join_project_path, :remote => true, :method => "post", :class => "sy_btn_green ml5 mt5" if @user == User.current %>
</p>
<% end %>
<% else %>
<% projects.each_with_index do |project, i| %>
<div class="syllabus_courses_list <%= i > 4 ? 'none' : ''%>" style="cursor: default;">
<div class="sy_courses_open">
<span class="icons_project_list fl mt5 mr10"></span>
<h3><%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%></h3>
<% unless project.is_public? %>
<span class="hw_icon_private fl"></span>
<% end %>
<% projectUser = User.where("id=?",project.user_id).first %>
<%=link_to "<span class='fr grayTxt'>创建者:#{projectUser.try(:realname) != " " ? projectUser.lastname + projectUser.firstname : projectUser.try(:login)}</span>".html_safe, user_path(projectUser) %>
<div class="cl"></div>
</div>
<div>
<p class="fl sy_p_grey">更新时间:<%= format_date(project.updatetime) %></p>
<div class=" fr">
<p class="list-info fr grayTxt">
<%= link_to project.members.count, member_project_path(project), :class => "c_blue" %><span class="mr5">成员&nbsp;&nbsp;|</span>
<%= link_to project.project_score.issue_num, project_issues_path(project), :class => "c_blue" %><span class="mr5">问题&nbsp;&nbsp;|</span>
<%= link_to project.project_score.attach_num, file_project_path(project), :class => "c_blue" %><span class="mr5">资源</span>
</p>
</div>
</div>
<div class="cl"></div>
</div>
<% end %>
<% if count > 5 %>
<div class="syllabus_courses_list">
<p class="new_projectlist_more"><a id="project_more_<%=list_type %>" href="javascript:void(0);" data-count="<%= count %>" data-init="0" onclick="expand_projects('#project_more_<%=list_type %>', '#project_li_<%=list_type %>', <%=count%>);">共<%=count %>个项目,点击全部展开</a></p>
</div>
<% end %>
<% end %>
</div><!--syllabus_courses_box end-->

View File

@ -1,3 +1,86 @@
<div class="syllabus_box">
<h2 class="syllabus_h2_top"><span class="icon_course fl mt7 mr5"></span>项目列表</h2>
<div class="syllabus_category">
<a class="sortdownbtn sort_no fr"></a><a href="#" class="sortTxt fr">人气</a>
<a class="sortupbtn fr"></a><a href="#" class="sortTxt fr ">时间</a>
<span class="grayTxt fl ">我创建的项目</span>
<div class="cl"></div>
</div>
<div class="syllabus_courses_box">
<% @projects.each do |project|%>
<div class="syllabus_courses_list" style="cursor: default">
<div class="sy_courses_open">
<span class="icons_project_list fl mt5 mr10"></span>
<h3><%= link_to "#{project.name}", project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%></h3>
<% unless project.is_public? %>
<span class="hw_icon_private fl"></span>
<% end %>
<% projectUser = User.where("id=?",project.user_id).first %>
<%=link_to "<span class='fr grayTxt'>创建者:#{projectUser.try(:realname) != " " ? projectUser.lastname + projectUser.firstname : projectUser.try(:login)}</span>".html_safe, user_path(projectUser) %>
<div class="cl"></div>
</div>
<div>
<p class="fl sy_p_grey">更新时间:<%= format_date(project.updated_on) %></p>
<div class=" fr">
<p class="list-info fr grayTxt">
<%= link_to project.members.count, member_project_path(project), :class => "c_blue" %><span class="mr5">成员&nbsp;&nbsp;|</span>
<%= link_to project.project_score.issue_num, project_issues_path(project), :class => "c_blue" %><span class="mr5">问题&nbsp;&nbsp;|</span>
<%= link_to project.project_score.attach_num, file_project_path(project), :class => "c_blue" %><span class="mr5">资源</span>
</p>
</div>
</div>
<div class="cl"></div>
</div>
<% end %>
<div class="syllabus_courses_list ">
<p class="new_projectlist_more"><a href="javascript:void(0);" >共100个项目点击全部展开</a></p>
</div>
</div><!--syllabus_courses_box end-->
</div><!--syllabus_box end-->
<div class="" style="height:20px; background:#eaebec;"></div>
<div class="syllabus_box">
<div class="syllabus_category">
<a class="sortdownbtn sort_no fr"></a><a href="#" class="sortTxt fr">人气</a>
<a class="sortupbtn fr"></a><a href="#" class="sortTxt fr ">时间</a>
<span class="grayTxt fl ">我参与的项目</span>
<div class="cl"></div>
</div>
<div class="syllabus_courses_box">
<% @projects.each do |project| %>
<div class="syllabus_courses_list" style="cursor: default;">
<div class="sy_courses_open">
<span class="icons_project_list fl mt5 mr10"></span>
<h3><%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%></h3>
<% unless project.is_public? %>
<span class="hw_icon_private fl"></span>
<% end %>
<% projectUser = User.where("id=?",project.user_id).first %>
<%=link_to "<span class='fr grayTxt'>创建者:#{projectUser.try(:realname) != " " ? projectUser.lastname + projectUser.firstname : projectUser.try(:login)}</span>".html_safe, user_path(projectUser) %>
<div class="cl"></div>
</div>
<div>
<p class="fl sy_p_grey">更新时间:<%= format_date(project.updated_on) %></p>
<div class=" fr">
<p class="list-info fr grayTxt">
<%= link_to project.members.count, member_project_path(project), :class => "c_blue" %><span class="mr5">成员&nbsp;&nbsp;|</span>
<%= link_to project.project_score.issue_num, project_issues_path(project), :class => "c_blue" %><span class="mr5">问题&nbsp;&nbsp;|</span>
<%= link_to project.project_score.attach_num, file_project_path(project), :class => "c_blue" %><span class="mr5">资源</span>
</p>
</div>
</div>
<div class="cl"></div>
</div>
<% end %>
<div class="syllabus_courses_list ">
<p class="new_projectlist_more"><a href="javascript:void(0);" >共100个项目点击全部展开</a></p>
</div>
</div><!--syllabus_courses_box end-->
</div><!--syllabus_box end-->
<div class="listbox" id="project-list">
<h2 class="list-h2">项目列表</h2>
<div class="category">

View File

@ -0,0 +1,5 @@
<% if @list_type.to_i == 1 %>
$("#user_projects_list").html('<%= escape_javascript(render :partial => 'users/project_list', :locals => {:projects => @projects, :list_type => 1, :count => @projects_count}) %>');
<% else %>
$("#user_join_projects_list").html('<%= escape_javascript(render :partial => 'users/project_list', :locals => {:projects => @projects, :list_type => 2, :count => @projects_count}) %>');
<% end %>

View File

@ -1 +1,39 @@
<%= render :partial => 'users/user_project_list'%>
<div class="syllabus_box">
<h2 class="syllabus_h2_top"><span class="icon_course fl mt7 mr5"></span>项目列表</h2>
<%= render :partial => 'users/my_projects'%>
<div class="" style="height:20px; background:#eaebec;"></div>
<%= render :partial => 'users/my_joined_projects'%>
</div>
<script type="text/javascript">
//如果右边的列表比左边的高度低则将右边的高度设为与左边对齐
$(function() {
var leftHeight = $("#LSide").height() - $(".fontGrey5").height() - 20;
var rightHeight = $(".homepageRight").height();
if (rightHeight < leftHeight) {
var diffHeight = leftHeight - rightHeight;
var tmpHeight = $(".syllabus_box").height() + diffHeight;
$(".syllabus_box").css("minHeight", tmpHeight);
}
});
function expand_projects(btnid,container,count){
var target = $(container).children('.syllabus_courses_list');
var btn = $(btnid);
if(btn.data('init')=='0'){
btn.data('init',1);
btn.html('点击收起');
target.show();
}else{
btn.data('init',0);
btn.html('共' + count + '个项目,点击全部展开');
target.hide();
target.eq(0).show();
target.eq(1).show();
target.eq(2).show();
target.eq(3).show();
target.eq(4).show();
btn.parent().parent().show();
}
}
</script>

View File

@ -456,4 +456,9 @@ zh:
# 版本库迁移
label_repository_migrate_dec: 注意Trustie版本库近期进行了一次大的改造历史版本需要转换成新的版本输入新的版本库名即可完成转换。 转换过程可能需要等待一段时间。
label_repository_name_dec: 版本库名仅小写字母a-z、数字、破折号-和下划线_可以使用长度必须在 1 到 254 个字符之间,一旦保存,标识无法修改。
label_repository_name_dec: 版本库名仅小写字母a-z、数字、破折号-和下划线_可以使用长度必须在 1 到 254 个字符之间,一旦保存,标识无法修改。
# pull requests
label_state_open: 待处理
label_state_closed: 关闭
label_state_merged: 已合并

View File

@ -626,6 +626,7 @@ RedmineApp::Application.routes.draw do
match 'user_projectlist', :to => 'users#user_projectlist', :via => :get, :as => "user_projectlist"
match 'sort_syllabus_list', :to => 'users#sort_syllabus_list', :via => :get, :as => "sort_syllabus_list"
match 'sort_project_list', :to => 'users#sort_project_list', :via => :get, :as => "sort_project_list"
get 'edit_brief_introduction'
get "user_resource"
@ -816,6 +817,9 @@ RedmineApp::Application.routes.draw do
get 'accept_pull_request'
get 'pull_request_commits'
get 'pull_request_changes'
get 'update_pull_request'
get 'pull_request_comments'
post 'create_pull_request_comment'
end
end

View File

@ -0,0 +1,11 @@
class CreatePullRequests < ActiveRecord::Migration
def change
create_table :pull_requests do |t|
t.integer :pull_request_id
t.integer :gpid
t.integer :user_id
t.timestamps
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -78,8 +78,8 @@ class Gitlab::Client
# @param [Integer] id The ID of a merge request.
# @param [String] note The content of a comment.
# @return [Gitlab::ObjectifiedHash] Information about created merge request comment.
def create_merge_request_comment(project, id, note)
post("/projects/#{project}/merge_request/#{id}/comments", :body => {:note => note})
def create_merge_request_comment(project, id, note, gid)
post("/projects/#{project}/merge_request/#{id}/comments?user_id=#{gid}", :body => {:note => note})
end
# Get a list of merge request commits.

View File

@ -160,9 +160,9 @@ div.thumbnails div {background:#fff;display:inline-block;margin-right:2px;}
.repos_files ul:hover{ background:#ffffdd;}
.repos_t_c li{ text-align:center;}
.pic_stats{display:block; background:url(/images/public_icon.png) 0px -548px no-repeat; width:20px; height:15px;}
.tree-age{width:10%; text-align:right;}
.tree-age{width:15%; text-align:right;}
.tree-author{width:10%; text-align:left;}
.tree-comments{width:40%; text-align:left;}
.tree-comments{width:35%; text-align:left;}
/* 里程碑 */
.roadmap_box{ background:#f8f8f8; width:648px; padding:10px; margin-top:5px; border:1px solid #ddd; color:#555;}
@ -511,8 +511,9 @@ a:hover.upload_btn_grey{background:#8a8a8a;}
.analysis-result-name {width:200px;}
.analysis-result-version {width:90px; text-align:right;}
.analysis-result-loc {width:60px; text-align:right;}
.analysis-result-debt {width:160px; text-align:right;}
.analysis-result-debt {width:80px; text-align:right;}
.analysis-result-time {width:150px; text-align:right;}
.analysis-result-edit {width:80px; text-align:right;}
.analysis-name-icon {background:url(/images/code-analysis-icon.png) -2px -148px no-repeat; width:16px; height:16px; display:inline-block; vertical-align:middle;}
@ -523,7 +524,7 @@ a:hover.upload_btn_grey{background:#8a8a8a;}
.project-merge-banner li a {padding:14px; font-size:14px; color:#555; display:inline-block;}
.project-number-dot {display:inline-block; min-width:10px; padding:3px 5px; font-size:12px; color:#888; line-height:1; vertical-align:middle; white-space:nowrap; text-align:center; background-color:#eee; border-radius:10px; margin-left:5px;}
.project-merge-content {}
.project-merge-content li {padding:10px; margin:0 -10px; background-color:#f9f9f9; border-bottom:1px solid #e5e5e5;}
.project-merge-content>li {padding:10px; margin:0 -10px; background-color:#f9f9f9; border-bottom:1px solid #e5e5e5;}
.no-merge-content {padding:10px 15px; color:#888;}
.new-merge-request {border-bottom:1px solid #ddd; padding-bottom:10px;}
.new-merge-wrap {font-size:13px; color:#484848; border-bottom:1px solid #ddd; padding:10px 0;}
@ -540,4 +541,42 @@ a:hover.upload_btn_grey{background:#8a8a8a;}
.merge-commit-code {width:150px; float:left; text-align:right;}
.merge-show {margin:-10px -10px 0 -10px; padding:10px; line-height:36px; border-bottom:1px solid #ddd;}
.open-status {color:#fff; padding:0 16px; background-color:#3b94d6; border-radius:2px; display:inline-block;}
.merge-commit-option {padding:12px; border:1px solid #ddd; background-color:#f9f9f9; border-radius:2px;}
.merge-commit-option {padding:12px; border:1px solid #ddd; background-color:#f9f9f9; border-radius:2px;}
.merge-discussion-content {font-size:13px; color: #484848; margin:0 -10px; padding:10px; border-bottom:1px solid #ddd;}
.merge-discussion-detail {font-size:13px; line-height:1.5em; color:#484848; margin-top:10px;}
.merge-discussion-automatic {background-color:#fdfdfd;}
.merge-discussion-input {margin:0 -10px; padding:10px; background-color:#f8f8f8;}
.merge-discussion-input textarea {width:720px; height:80px; font-size:13px; line-height:16px; color:#484848; padding:5px;}
/*新版项目列表新增*/
.new_project_title{ font-size:16px; color:#333; max-width:560px; font-weight:normal;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.icons_project_list{ width:8px; height:8px; border:2px solid #fff; background:#3b94d6;-webkit-border-radius:50px;-moz-border-radius:50px;-o-border-radius:50px;border-radius:50px;-webkit-box-shadow: 0px 2px 5px rgba(146, 153, 169, 0.5);-moz-box-shadow: 0px 2px 5px rgba(146, 153, 169, 0.5);box-shadow: 0px 2px 5px rgba(146, 153, 169, 0.5); }
.new_projectlist_more{ text-align:center;}
.new_projectlist_more a:hover{ color:#3b94d6;}
/*新版项目引用的新版课程大纲中的公共样式*/
.icons_tishi{
width: 110px;
height: 110px;
margin: 135px auto 20px;
}
.sy_tab_con_p{
font-size: 16px;
text-align: center;
margin-bottom:100px;
color:#888;
}
a.sy_btn_green{
display:inline-block;
color: #fff;
background: #60b25e;
text-align: center;
font-size: 12px;
padding:0 15px;
height: 30px;
line-height: 30px;
-webkit-border-radius:3px;
-moz-border-radius:3px;
-o-border-radius:3px;
border-radius:3px;
}
a:hover.sy_btn_green{ background: #51a74f;}

View File

@ -474,6 +474,7 @@ a.f_grey:hover {color:#000000;}
.shadowbox_news_list{ max-height:400px; overflow:hidden;}
.shadowbox_news_list a{ color:#999;}
.shadowbox_news_list li{ height:40px; border-bottom:1px dashed #ebebeb; line-height:40px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis; padding:0 10px;}
.shadowbox_news_list li:last-child {border-bottom:none;}
.shadowbox_news_list li:hover{ background-color:#eee;}
span.shadowbox_news_user{ color:#3b94d6;}
a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; color:#3b94d6; text-align:center;border-top:1px solid #eee;}

View File

@ -0,0 +1,8 @@
FactoryGirl.define do
factory :pull_request do
pull_request_id 1
gpid 1
user_id 1
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe PullRequest, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end