diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index b68db3563..6f245a92b 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -190,7 +190,7 @@ class PullRequestsController < ApplicationController begin status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid) # 接受后,给用户发消息 - send_message_to_author(@project.id, status.author.try(:user_name), params[:id], 2) + send_message_to_author(@project.id, status.author.try(:username), params[:id], 2) respond_to do |format| format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)} @@ -220,8 +220,8 @@ class PullRequestsController < ApplicationController user = User.find_by_login(request.author.try(:username)) status = params[:state] == "close" ? 4 : 3 send_message_to_manager(@project.id, params[:id], status) - if !is_project_manager?(user.id, @project.id) - send_message_to_author(@project, user.login, request.id, status) + if is_project_manager?(User.current.id, @project.id) + send_message_to_author(@project.id, user.login, request.id, status) end respond_to do |format| format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} @@ -350,7 +350,9 @@ class PullRequestsController < ApplicationController :forge_message_id => pull_request_id, :forge_message_type => "PullRequest", :viewed => true, - :status => status) + :status => status, + :operate_user_id => User.current.id, + ) end def authorize_logged diff --git a/app/models/forge_message.rb b/app/models/forge_message.rb index bc514025e..e131eb600 100644 --- a/app/models/forge_message.rb +++ b/app/models/forge_message.rb @@ -1,7 +1,7 @@ class ForgeMessage < ActiveRecord::Base # status在不同的类中,作用不同 # Isseu: satus nil:发布了缺陷;:1:缺陷计划完成日志到了提醒 - attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed, :secret_key, :status + attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed, :secret_key, :status, :operate_user_id belongs_to :forge_message ,:polymorphic => true belongs_to :project diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 282df48c3..05b8d40d0 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -27,17 +27,17 @@ <% unless @entries.nil? %> ZIP下载 - <% if User.current.member_of?(@project) && @project.is_public? %> - <% if quality_analysis(User.current.try(:login), @repository.id).nil? %> - <%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "1"), :remote => true, :class => "btn_zipdown fr" %> - <% else %> - <%= link_to "重新分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "2"), :remote => true, :class => "btn_zipdown fr" %> - <% end %> - <% end %> - <% end %> - <% unless QualityAnalysis.where(:project_id => @project.id).first.nil? %> - <%= link_to "代码分析结果", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fr" %> + <%# if User.current.member_of?(@project) && @project.is_public? %> + <%# if quality_analysis(User.current.try(:login), @repository.id).nil? %> + <%#= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "1"), :remote => true, :class => "btn_zipdown fr" %> + <%# else %> + <%#= link_to "重新分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "2"), :remote => true, :class => "btn_zipdown fr" %> + <%# end %> + <%# end %> <% end %> + <%# unless QualityAnalysis.where(:project_id => @project.id).first.nil? %> + <%#= link_to "代码分析结果", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fr" %> + <%# end %>
<%=link_to "代码统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator, :default_branch => @g_default_branch ), :class => "fl vl_zip" %> diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb index 5204a9bff..10a14ffa9 100644 --- a/app/views/users/_user_message_forge.html.erb +++ b/app/views/users/_user_message_forge.html.erb @@ -200,12 +200,12 @@
  • <% send_message_user = PullRequest.where(:pull_request_id => ma.forge_message_id) %> - <% author = User.find(send_message_user[0].user_id) %> + <% author = User.find(ma.operate_user_id.nil? ? 2 : ma.operate_user_id) %> <%= link_to image_tag(url_to_avatar(author), :width => "30", :height => "30"), user_path(author), :target => '_blank' %>
  • - <%= link_to User.find(send_message_user[0].user_id).show_name, user_path(send_message_user[0].user_id), + <%= link_to User.find(author.id).show_name, user_path(author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> "> <%= pull_request_message_status(ma) %> diff --git a/db/migrate/20161202073523_add_aperate_idto_forge_message.rb b/db/migrate/20161202073523_add_aperate_idto_forge_message.rb new file mode 100644 index 000000000..c58fb5afd --- /dev/null +++ b/db/migrate/20161202073523_add_aperate_idto_forge_message.rb @@ -0,0 +1,5 @@ +class AddAperateIdtoForgeMessage < ActiveRecord::Migration + def change + add_column :forge_messages, :operate_user_id, :integer + end +end