Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2016-08-26 18:34:44 +08:00
commit 816a480991
18 changed files with 2896 additions and 2396 deletions

View File

@ -325,6 +325,7 @@ class FilesController < ApplicationController
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
show_attachments @containers
get_attachment_for_tip(@all_attachments)
@tag_list = attachment_tag_list @all_attachments
@ -377,6 +378,7 @@ class FilesController < ApplicationController
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
show_attachments @containers
get_attachment_for_tip(@all_attachments)
@tag_list = attachment_tag_list @all_attachments
@ -440,6 +442,39 @@ class FilesController < ApplicationController
end
# 获取提示中私有、公开总数信息
def get_attachment_for_tip all_attachment
@tip_all_public_attachments = all_attachment.select{|attach| attach.is_public == 1}.count
if params[:project_id]
if User.current.member_of?(@project) || User.current.admin?
@tip_all_attachments = all_attachment.count
@tip_all_private_attachments = all_attachment.select{|attach| attach.is_public == 0}.count
else
if params[:tag_name]
@tip_all_attachments = all_attachment.count
@tip_all_private_attachments = 0
else
@tip_all_attachments = Attachment.where(:container_id => params[:project_id], :container_type => "Project").count
@tip_all_private_attachments = Attachment.where(:container_id => params[:project_id], :container_type => "Project", :is_public => 0).count
end
end
elsif params[:course_id]
if User.current.member_of_course?(@course) || User.current.admin?
@tip_all_attachments = all_attachment.count
@tip_all_private_attachments = all_attachment.select{|attach| attach.is_public == 0}.count
else
if params[:tag_name]
@tip_all_attachments = all_attachment.count
@tip_all_private_attachments = 0
else
@tip_all_attachments = Attachment.where(:container_id => params[:course_id], :container_type => "Course").count
@tip_all_private_attachments = Attachment.where(:container_id => params[:course_id], :container_type => "Course", :is_public => 0).count
end
end
end
end
def quote_resource_show
@file = Attachment.find(params[:id])
@can_quote = attachment_candown @file
@ -883,6 +918,7 @@ class FilesController < ApplicationController
end
@all_attachments = @result
get_attachment_for_tip(@all_attachments)
@limit = 10
@feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']

View File

@ -1,8 +1,10 @@
class PullRequestsController < ApplicationController
before_filter :authorize_logged
before_filter :find_project_and_repository
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
@ -235,6 +237,13 @@ class PullRequestsController < ApplicationController
end
private
def authorize_logged
if !User.current.logged?
redirect_to signin_path
return
end
end
def connect_gitlab
@g = Gitlab.client
end

View File

@ -241,6 +241,19 @@ class QualityAnalysisController < ApplicationController
complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read
@complexity =JSON.parse(complexity_date).first
# 获取排名结果
@g = Gitlab.client
author_infos = @g.rep_user_stats(@project.gpid, :rev => @branch)
@user_quality_infos = []
author_infos.each do |author_info|
email = author_info.email
changes = author_info.changes.to_i
user_issues = open(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}&resolved=false").read
issue_count = JSON.parse(user_issues)["total"].to_i
ratio = (changes == 0 ? 0 : format("%0.4f",issue_count.to_f/changes.to_f))
@user_quality_infos << {:email => email, :changes => changes, :issue_count => issue_count, :ratio => ratio}
end
# 按名称转换成hash键值对
@ha = {}
@complexity["msr"].each do |com|

View File

@ -820,6 +820,11 @@ module ApplicationHelper
return @result
end
def show_attachment_tip container_id, container_type
atts = Attachment.where(:container_id => container_id, :container_type => container_type, :is_public => 0)
atts.count > 0 ? true :false
end
# 必须是项目成,项目必须提交过代码
def allow_pull_request project
return false if project.gpid.nil?

View File

@ -94,7 +94,7 @@
</p>
</div>
<% end %>
<div class="resources mt10" style="padding-bottom:5px;">
<div class="resources mt10 pr" style="padding-bottom:5px;">
<div class="reTop mb5">
<%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 'researchBox fl',:style=>"padding: 0px"%>
@ -115,13 +115,21 @@
</div>
<div class="cl"></div>
<div class="re_con_top">
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p>
<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">
<%= render :partial => "files/tip_attachment_count" %>
</p>
<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} %>
</p>
</div>
</div>
<div class="cl"></div>
<div class="resource_tip_box fontGrey2">
<em></em>
<span></span>
<p class="mb5">私有资源:<br/>仅对本班级成员可见</p>
<p>公共资源:<br/>对所有用户可见</p>
</div>
</div>
<div id="course_list">
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>

View File

@ -65,7 +65,7 @@
</p>
</div>
<% end %>
<div class="resources mt10" style="padding-bottom:5px;">
<div class="resources mt10 pr" style="padding-bottom:5px;">
<div class="reTop mb5">
<%= form_tag( search_project_project_files_path(@project), method: 'get',:class => "re_search",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%>
@ -85,7 +85,9 @@
</div>
<div class="cl"></div>
<div class="re_con_top">
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p>
<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">
<%= render :partial => "files/tip_attachment_count" %>
</p>
<p class="f_r" style="color: #808080">
<% if @order == "asc" %>
按&nbsp;<%= 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"} %>&nbsp;/&nbsp;
@ -100,6 +102,14 @@
</div>
</div>
<div class="cl"></div>
<% if !User.current.member_of?(@project) && show_attachment_tip(@project.id, "Project") %>
<div class="resource_tip_box fontGrey2">
<em></em>
<span></span>
<p class="mb5">私有资源:<br/>仅对本项目成员可见</p>
<p>公共资源:<br/>对所有用户可见</p>
</div>
<% end %>
</div>
<div id="course_list">
<%= render :partial => 'project_list',:locals => {project: @project, all_attachments: @all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments} %>

View File

@ -0,0 +1,15 @@
共有&nbsp;<span id="attachment_count"><%= @tip_all_attachments %></span>&nbsp;个资源
<span id="attachment_count_public" class="fontGrey2 ml10" style="font-weight: normal;">公共资源:<%= @tip_all_public_attachments %>个</span>
<% if @project %>
<% if !User.current.member_of?(@project) && params[:tag_name] %>
<span id="attachment_count_private" class="fontGrey2 ml10" style="font-weight: normal;">私有资源0个</span>
<% else %>
<span id="attachment_count_private" class="fontGrey2 ml10" style="font-weight: normal;">私有资源:<%= @tip_all_private_attachments %>个</span>
<% end %>
<% elsif @course %>
<% if !User.current.member_of_course?(@course) && params[:tag_name] %>
<span id="attachment_count_private" class="fontGrey2 ml10" style="font-weight: normal;">私有资源0个</span>
<% else %>
<span id="attachment_count_private" class="fontGrey2 ml10" style="font-weight: normal;">私有资源:<%= @tip_all_private_attachments %>个</span>
<% end %>
<% end %>

View File

@ -3,5 +3,6 @@
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
<% 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}) %>");
$("#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 %>');
<% end %>

View File

@ -1,5 +1,6 @@
<%# 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 %>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
<% homework_num = visable_course_homework @course %>

View File

@ -40,12 +40,12 @@
</div>
<% end %>
<% if allow_pull_request(@project) %>
<div class="subNav">
<%= link_to "Pull Requests", project_pull_requests_path(@project), :class => "f14 c_blue02" %>
<div class="subNav">
<%= link_to "Pull Requests", project_pull_requests_path(@project), :class => "f14 c_blue02" %>
<% if allow_pull_request(@project) %>
<%= link_to "+新建请求", new_project_pull_request_path(:project_id => @project.id), :class => "subnav_green" %>
</div>
<% end %>
<% end %>
</div>
<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %>
<% if visible_repository?(@project) %>

View File

@ -5,8 +5,10 @@
<div id="pull_request_show">
<div id="mergeShow" class="f14 fontGrey2 merge-show">
<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" %>
<% if User.current.login == @request.author.try(:username) || is_project_manager?(User.current.id, @project.id) %>
<% 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 %>
<% end %>
<div class="cl"></div>
</div>

View File

@ -3,8 +3,9 @@
<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;" %>
<% if allow_pull_request(@project) %>
<%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
<% end %>
<div class="cl"></div>
</ul>
<div class="cl"></div>

View File

@ -127,46 +127,35 @@
<p class="fontBlue2"><%= @ha["functions"].to_i %></p>
</div>
</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">-->
<!--<ul class="contribute-list">-->
<!--<li class="fl fontGrey2 contribute-list-avatar">&nbsp;</li>-->
<!--<li class="fl fontGrey2 contribute-list-code">代码行数</li>-->
<!--<li class="fl fontGrey2 contribute-list-problem">引入质量问题数</li>-->
<!--<li class="fl fontGrey2 contribute-list-rate">引入质量问题数/代码行数</li>-->
<!--<div class="cl"></div>-->
<!--</ul>-->
<!--<ul class="contribute-list">-->
<!--<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">-->
<!--<div class="mt8"><img src="images/homepageImage.jpg" width="50" class="image-cir" />-->
<!--<p class="fontGrey2 hidden">小明</p>-->
<!--</div>-->
<!--</li>-->
<!--<li class="fl fontGrey2 contribute-list-code contribute-list-height contribute-list-line-height">18340</li>-->
<!--<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height">230</li>-->
<!--<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height">.012540</li>-->
<!--<div class="cl"></div>-->
<!--</ul>-->
<!--<ul class="contribute-list">-->
<!--<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">-->
<!--<div class="mt8"><img src="images/homepageImage.jpg" width="50" class="image-cir" />-->
<!--<p class="fontGrey2 hidden">小王</p>-->
<!--</div>-->
<!--</li>-->
<!--<li class="fl fontGrey2 contribute-list-code contribute-list-height contribute-list-line-height">834</li>-->
<!--<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height">34</li>-->
<!--<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height">.04077</li>-->
<!--<div class="cl"></div>-->
<!--</ul>-->
<!--<ul class="contribute-list">-->
<!--<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">-->
<!--<div class="mt8"><img src="images/homepageImage.jpg" width="50" class="image-cir" />-->
<!--<p class="fontGrey2 hidden">小亮</p>-->
<!--</div>-->
<!--</li>-->
<!--<li class="fl fontGrey2 contribute-list-code contribute-list-height contribute-list-line-height">134</li>-->
<!--<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height">10</li>-->
<!--<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height">.07462</li>-->
<!--<div class="cl"></div>-->
<!--</ul>-->
<!--</div>-->
<% unless @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-block mt10 f12">
<ul class="contribute-list">
<li class="fl fontGrey2 contribute-list-avatar">&nbsp;</li>
<li class="fl fontGrey2 contribute-list-code">代码行数</li>
<li class="fl fontGrey2 contribute-list-problem">引入质量问题数</li>
<li class="fl fontGrey2 contribute-list-rate">引入质量问题数/代码行数</li>
<div class="cl"></div>
</ul>
<% @user_quality_infos.each do |author_info| %>
<% user = get_user_by_mail(author_info[:email]) %>
<% unless author_info[:changes] == 0 %>
<ul class="contribute-list">
<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">
<div class="mt8">
<%=link_to image_tag(url_to_avatar(user), :width => "50", :height => "30"), user_path(user), :class => "image-cir", :target => '_blank' %>
<p class="fontGrey2 hidden"><%=link_to (user.id == 2 ? author_info[:email] : user.show_name), user_path(user) %></p>
</div>
</li>
<li class="fl fontGrey2 contribute-list-code contribute-list-height contribute-list-line-height"><%= author_info[:changes] %></li>
<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height"><%= author_info[:issue_count] %></li>
<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height"><%= author_info[:ratio] %></li>
<div class="cl"></div>
</ul>
<% end %>
<% end %>
</div>
<% end %>

View File

@ -72,6 +72,7 @@
l(:button_delete),
{:controller => 'issues',:action => 'delete_journal', :id => activity_id,:journal_id=>comment.id, :user_activity_id => user_activity_id},
:method => 'get',
:confirm => l(:text_are_you_sure),
:remote=>true,
:class => 'fr mr20',
:title => l(:button_delete)

File diff suppressed because it is too large Load Diff

View File

@ -117,6 +117,11 @@ class Gitlab::Client
end
alias_method :repo_rep_stats, :rep_stats
def rep_user_stats(project, options={})
get("/projects/#{project}/repository/rep_user_stats", :query => options)
end
alias_method :repo_rep_stats, :rep_stats
# Gets a tree activities of project repository.
#
# @example

View File

@ -607,11 +607,11 @@ function regexTopicDescription()
$("#message_content_span").css('color','#ff0000');
return false;
}
else if(name.length >=6000){
$("#message_content_span").text("描述最多3000个汉字(或6000个英文字符)");
$("#message_content_span").css('color','#ff0000');
return false;
}
// else if(name.length >=6000){
// $("#message_content_span").text("描述最多3000个汉字(或6000个英文字符)");
// $("#message_content_span").css('color','#ff0000');
// return false;
// }
else
{
$("#message_content_span").text("填写正确");
@ -621,11 +621,11 @@ function regexTopicDescription()
}
function submit_topic_project()
{
// if(regexTopicSubject() && regexTopicDescription())
// {
if(regexTopicSubject() && regexTopicDescription())
{
message_content_editor.sync();
$("#message-form-project").submit();
// }
}
}
function reset_topic(){

View File

@ -1418,7 +1418,7 @@ a:hover.comment_ding_link{ color:#269ac9;}
}
a.syllabusbox_a_blue{
color:#3b94d6 !important;
}
.icons_tishi{
width: 110px;
@ -1445,4 +1445,11 @@ a.sy_btn_green{
-o-border-radius:3px;
border-radius:3px;
}
a:hover.sy_btn_green{ background: #51a74f;}
a:hover.sy_btn_green{ background: #51a74f;}
/*资源提示框*/
.resource_tip_box {position:absolute; padding:5px 10px; white-space:nowrap; background-color:#fff; right:-150px; top:20px; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5);}
.resource_tip_box em {display:block; border-width:10px; position:absolute;top:35px; left:-20px; border-style:dashed solid dashed dashed; border-color:transparent #eaeaea transparent transparent; font-size:0; line-height:0;}
.resource_tip_box span {display:block; border-width:10px; position:absolute;top:35px; left:-18px; border-style:dashed solid dashed dashed; border-color:transparent #fff transparent transparent; font-size:0; line-height:0;}