diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index cd3870e9a..70bce9566 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -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'] diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index a0b275dc7..9fbe5bc3c 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -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| diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0c0e0919e..ffd30efc3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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? diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 946449680..5291c2d06 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -94,7 +94,7 @@

<% end %> -
+
<%= 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 @@
-

共有 <%= @all_attachments.count%> 个资源

+

+ <%= render :partial => "files/tip_attachment_count" %> +

<%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>

+
+ + +

私有资源:
仅对本班级成员可见

+

公共资源:
对所有用户可见

+
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %> diff --git a/app/views/files/_project_file.html.erb b/app/views/files/_project_file.html.erb index 40e5163a8..ebda40e6e 100644 --- a/app/views/files/_project_file.html.erb +++ b/app/views/files/_project_file.html.erb @@ -65,7 +65,7 @@

<% end %> -
+
<%= 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 @@
-

共有 <%= @all_attachments.count%> 个资源

+

+ <%= render :partial => "files/tip_attachment_count" %> +

<% 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"} %> /  @@ -100,6 +102,14 @@

+ <% if !User.current.member_of?(@project) && show_attachment_tip(@project.id, "Project") %> +
+ + +

私有资源:
仅对本项目成员可见

+

公共资源:
对所有用户可见

+
+ <% end %>
<%= render :partial => 'project_list',:locals => {project: @project, all_attachments: @all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments} %> diff --git a/app/views/files/_tip_attachment_count.html.erb b/app/views/files/_tip_attachment_count.html.erb new file mode 100644 index 000000000..b50e7bcaa --- /dev/null +++ b/app/views/files/_tip_attachment_count.html.erb @@ -0,0 +1,15 @@ +共有 <%= @tip_all_attachments %> 个资源 +公共资源:<%= @tip_all_public_attachments %>个 +<% if @project %> + <% if !User.current.member_of?(@project) && params[:tag_name] %> + 私有资源:0个 + <% else %> + 私有资源:<%= @tip_all_private_attachments %>个 + <% end %> +<% elsif @course %> + <% if !User.current.member_of_course?(@course) && params[:tag_name] %> + 私有资源:0个 + <% else %> + 私有资源:<%= @tip_all_private_attachments %>个 + <% end %> +<% end %> diff --git a/app/views/files/search_tag_attachment.js.erb b/app/views/files/search_tag_attachment.js.erb index dff75023b..8aaff5aa5 100644 --- a/app/views/files/search_tag_attachment.js.erb +++ b/app/views/files/search_tag_attachment.js.erb @@ -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 %> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 86a0a5518..027ef73e0 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -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 %> diff --git a/app/views/quality_analysis/_show.html.erb b/app/views/quality_analysis/_show.html.erb index f07225cc7..2fda1e727 100644 --- a/app/views/quality_analysis/_show.html.erb +++ b/app/views/quality_analysis/_show.html.erb @@ -127,46 +127,35 @@

<%= @ha["functions"].to_i %>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +<% unless @user_quality_infos.blank? %> +
贡献统计
+
+ + + <% @user_quality_infos.each do |author_info| %> + <% user = get_user_by_mail(author_info[:email]) %> + <% unless author_info[:changes] == 0 %> + + <% end %> + <% end %> + +
+<% end %> + diff --git a/app/views/users/_news_replies.html.erb b/app/views/users/_news_replies.html.erb index 1da4bc85e..fcbe59ebf 100644 --- a/app/views/users/_news_replies.html.erb +++ b/app/views/users/_news_replies.html.erb @@ -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) diff --git a/db/schema.rb b/db/schema.rb index 47b3bf210..1e20df076 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160810081337) do +ActiveRecord::Schema.define(:version => 20160811084401) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -2207,6 +2207,7 @@ ActiveRecord::Schema.define(:version => 20160810081337) do t.integer "simi_id" t.integer "simi_value" t.integer "work_status", :default => 0 + t.datetime "commit_time" end add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" @@ -2510,8 +2511,9 @@ ActiveRecord::Schema.define(:version => 20160810081337) do t.string "remark" t.integer "groupid" t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "bindtype", :default => 0 end create_table "users", :force => true do |t| diff --git a/lib/gitlab-cli/lib/gitlab/client/repositories.rb b/lib/gitlab-cli/lib/gitlab/client/repositories.rb index e998ab56b..80d1058b5 100644 --- a/lib/gitlab-cli/lib/gitlab/client/repositories.rb +++ b/lib/gitlab-cli/lib/gitlab/client/repositories.rb @@ -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 diff --git a/public/javascripts/project.js b/public/javascripts/project.js index 13ed76aa4..4d2c0c91a 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -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(){ diff --git a/public/stylesheets/css/public.css b/public/stylesheets/css/public.css index f9d344cf3..663c9a69a 100644 --- a/public/stylesheets/css/public.css +++ b/public/stylesheets/css/public.css @@ -100,7 +100,7 @@ a.sendButtonBlue:hover {color:#ffffff;} a.resourcesTypeAll {background:url(../images/homepage_icon.png) -180px -89px no-repeat; padding-left:23px;} a.resourcesTypeAtt {background:url(../images/homepage_icon.png) -180px -49px no-repeat; padding-left:23px;} a.resourcesTypeUser {background:url(../images/homepage_icon.png) -178px -453px no-repeat; padding-left:23px;} -.resourcesType {width:75px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 20px; left:-90px; font-size:12px; color:#888888; display:none; line-height:2;} +.resourcesType {width:75px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 20px; left:-90px; font-size:12px; color:#888888; display:none; line-height:2;z-index: 999;} /*.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;}*/ /*.resourcesUploadBox:hover {background-color:#0781b4;}*/ @@ -1418,4 +1418,9 @@ a:hover.comment_ding_link{ color:#269ac9;} } a.syllabusbox_a_blue{ color:#3b94d6 !important; -} \ No newline at end of file +} + +/*资源提示框*/ +.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;} \ No newline at end of file