pullrequest发送消息

This commit is contained in:
daiao 2016-12-02 16:18:31 +08:00
parent ef86b6da2a
commit b48fc7ba3b
5 changed files with 24 additions and 17 deletions

View File

@ -190,7 +190,7 @@ class PullRequestsController < ApplicationController
begin begin
status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid) 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| respond_to do |format|
format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)} 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)) user = User.find_by_login(request.author.try(:username))
status = params[:state] == "close" ? 4 : 3 status = params[:state] == "close" ? 4 : 3
send_message_to_manager(@project.id, params[:id], status) send_message_to_manager(@project.id, params[:id], status)
if !is_project_manager?(user.id, @project.id) if is_project_manager?(User.current.id, @project.id)
send_message_to_author(@project, user.login, request.id, status) send_message_to_author(@project.id, user.login, request.id, status)
end end
respond_to do |format| respond_to do |format|
format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} 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_id => pull_request_id,
:forge_message_type => "PullRequest", :forge_message_type => "PullRequest",
:viewed => true, :viewed => true,
:status => status) :status => status,
:operate_user_id => User.current.id,
)
end end
def authorize_logged def authorize_logged

View File

@ -1,7 +1,7 @@
class ForgeMessage < ActiveRecord::Base class ForgeMessage < ActiveRecord::Base
# status在不同的类中作用不同 # status在不同的类中作用不同
# Isseu satus nil发布了缺陷1缺陷计划完成日志到了提醒 # 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 :forge_message ,:polymorphic => true
belongs_to :project belongs_to :project

View File

@ -27,17 +27,17 @@
<!--quality_analysis--> <!--quality_analysis-->
<% unless @entries.nil? %> <% unless @entries.nil? %>
<a href="<%= @zip_path %>" class="btn_zipdown fr" onclick="">ZIP下载</a> <a href="<%= @zip_path %>" class="btn_zipdown fr" onclick="">ZIP下载</a>
<% if User.current.member_of?(@project) && @project.is_public? %> <%# if User.current.member_of?(@project) && @project.is_public? %>
<% if quality_analysis(User.current.try(:login), @repository.id).nil? %> <%# 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" %> <%#= 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 %> <%# 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" %> <%#= 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 %> <%# 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 %> <% 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 %>
<div class="fl mt5 ml15"> <div class="fl mt5 ml15">
<%=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" %> <%=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" %>

View File

@ -200,12 +200,12 @@
<li class="homepageNewsPortrait fl"> <li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"> <a href="javascript:void(0);">
<% send_message_user = PullRequest.where(:pull_request_id => ma.forge_message_id) %> <% 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 image_tag(url_to_avatar(author), :width => "30", :height => "30"), user_path(author), :target => '_blank' %>
</a> </a>
</li> </li>
<li class="homepageNewsPubType fl"> <li class="homepageNewsPubType fl">
<%= 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' %> :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>"> <span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">
<%= pull_request_message_status(ma) %> <%= pull_request_message_status(ma) %>

View File

@ -0,0 +1,5 @@
class AddAperateIdtoForgeMessage < ActiveRecord::Migration
def change
add_column :forge_messages, :operate_user_id, :integer
end
end