diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d14bccc4e..ad0fab173 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -372,7 +372,8 @@ class ApplicationController < ActionController::Base return true end - if allowed + + if allowed || (params[:type] && params[:type] == "wechat" ) true else if @project && @project.archived? diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 5d1345f24..3986acc0a 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -130,7 +130,12 @@ class AttachmentsController < ApplicationController def download # modify by nwb # 下载添加权限设置 - candown = attachment_candown @attachment + if (params[:type] && params[:type] == "wechat" ) + candown = true + else + candown = attachment_candown @attachment + end + if candown || User.current.admin? || User.current.id == @attachment.author_id if stale?(:etag => @attachment.digest) if params[:preview] == 'true' @@ -710,7 +715,7 @@ class AttachmentsController < ApplicationController def has_login unless (@attachment && @attachment.container_type == "Organization").nil? unless (@attachment && @attachment.container_type == "PhoneAppVersion").nil? - render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download) + render_403 if (!User.current.logged? && !(params[:type] && params[:type] == "wechat")) && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download) end end end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index bdbdc7d9c..6fb2868bc 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -132,16 +132,13 @@ class IssuesController < ApplicationController User.current.at_messages.unviewed('Journal', j.id).each {|x| x.viewed!} end - # 缺陷状态更新 - query_journals = @issue.journals - query_journals.each do |query_journal| - query_journal.forge_messages.each do |f| - if User.current.id == f.user_id - f.update_attributes(:viewed => true) - end - end - end - # end + # 缺陷状态消息更新 + query_journals_ids = @issue.journals.map{|journal| journal.id} + if query_journals_ids.length > 0 + query_journals = ForgeMessage.where("user_id =? and forge_message_type =? and forge_message_id in (#{query_journals_ids.join(",")})", User.current.id, "Journal") + query_journals.update_all(:viewed => true) + end + @jour_reply = Journal.new @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all @journals.each_with_index {|j,i| j.indice = i+1} diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 56ffc77e2..2b31cae13 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -88,7 +88,7 @@ class OrganizationsController < ApplicationController shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) project_ids = (@organization.projects.map(&:id) - shield_project_ids) << 0 - course_ids = (@organization.courses.map(&:id) - shield_course_ids) << 0 + course_ids = (@organization.courses.not_deleted.map(&:id) - shield_course_ids) << 0 course_types = "('Message','News','HomeworkCommon','Poll','Course')" @project_acts = get_project_activities_org @organization, project_ids @course_acts = get_course_activities_org @organization, course_ids @@ -140,7 +140,7 @@ class OrganizationsController < ApplicationController shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0 - course_ids = (@organization.courses.map(&:id)-shield_course_ids) << 0 + course_ids = (@organization.courses.not_deleted.map(&:id)-shield_course_ids) << 0 course_types = "('Message','News','HomeworkCommon','Poll','Course')" case params[:type] when nil diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 365889640..4e522ec73 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -252,7 +252,7 @@ class QualityAnalysisController < ApplicationController unresolved_issue_count = JSON.parse(unresolved_issues)["total"].to_i all_issues = open(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}").read all_issue_count = JSON.parse(all_issues)["total"].to_i - ratio = (changes == 0 ? 0 : format("%0.4f",unresolved_issue_count.to_f/changes.to_f)) + ratio = ((changes == 0 || all_issue_count == 0) ? 0 : format("%0.4f",all_issue_count.to_f/changes.to_f)) @user_quality_infos << {:email => email, :changes => changes, :unresolved_issue_count => unresolved_issue_count, :ratio => ratio, :all_issue_count => all_issue_count} end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c1d6950fa..94b0b2c6e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -417,13 +417,13 @@ module ApplicationHelper end # status_id:3、已解决 5、已关闭 if issue.status_id == 3 - s = link_to text, issue_path(issue), :class => "text_line_s", :title => title + s = link_to text, issue_path(issue), :class => "text_line_s fl", :title => title elsif issue.status_id == 5 - s = link_to text, issue_path(issue), :class => "text_line_s del_line", :title => title + s = link_to text, issue_path(issue), :class => "text_line_s del_line fl", :title => title else - s = link_to text, issue_path(issue), :class => "c_blue", :title => title + s = link_to text, issue_path(issue), :class => "c_blue fl", :title => title end - s << h(": #{subject}") if subject + s << h(": #{subject}".html_safe) if subject s = h("#{issue.project} - ") + s if options[:project] s end @@ -652,7 +652,7 @@ module ApplicationHelper s << watcher_link(@project, User.current)#, ['whiteButton']) s << "" end - s << (render :partial => 'projects/project', :locals => {:project => project}).to_s + s << (render :partial => 'projects/tracker_project', :locals => {:project => project}).to_s else s << (render :partial => 'projects/course', :locals => {:project => project}).to_s end @@ -832,9 +832,15 @@ module ApplicationHelper atts.count > 0 ? true :false end - # 必须是项目成,项目必须提交过代码 + # 如果Pull Request数量为0就显示在更多中 + def allow_show_pull_request project + g = Gitlab.client + count = g.merge_requests(project.gpid).count + end + + # 必须是项目成员,项目必须提交过代码 def allow_pull_request project - return false if project.gpid.nil? + return 0 if project.gpid.nil? g = Gitlab.client count = g.user_static(project.gpid, :rev => "master").count count diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb index 5e3a927da..80cc40fb0 100644 --- a/app/views/admin/projects.html.erb +++ b/app/views/admin/projects.html.erb @@ -64,7 +64,6 @@