优化pullrequest代码
This commit is contained in:
parent
0f4deef8f6
commit
3126d8312f
|
@ -192,13 +192,17 @@ class PullRequestsController < ApplicationController
|
|||
def accept_pull_request
|
||||
begin
|
||||
@status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
|
||||
# 接受后,给用户发消息
|
||||
send_message_to_author(@project.id, @status.author.try(:username), params[:id], 2)
|
||||
# 更新所有管理员的这条pullrequest消息为“已读”,并修改status值
|
||||
ForgeMessage.where(:forge_message_id => params[:id].to_i, :project_id => @project.id, :forge_message_type => "PullRequest", :status => 1).update_all(:viewed => true)
|
||||
user = User.find_by_login(@status.author.try(:username))
|
||||
# 更新所有管理员的这条pullrequest消息
|
||||
ForgeMessage.where(:forge_message_id => params[:id].to_i, :project_id => @project.id, :forge_message_type => "PullRequest").update_all(:status => 2, :operate_user_id => User.current.id, :updated_at => Time.now)
|
||||
# 更新自己的消息为已读
|
||||
ForgeMessage.where(:forge_message_id => params[:id].to_i, :project_id => @project.id, :forge_message_type => "PullRequest", :user_id => User.current.id).update_all(:viewed => true)
|
||||
# 更新pullrequest的status字段
|
||||
PullRequest.where(:pull_request_id => params[:id].to_i).update_all(:status => 2)
|
||||
|
||||
# 接受后,给用户发消息
|
||||
if ForgeMessage.where(:forge_message_id => params[:id].to_i, :project_id => @project.id, :forge_message_type => "PullRequest", :user_id => user.id).count == 0
|
||||
send_message_to_author(@project.id, @status.author.try(:username), params[:id], 2)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js{redirect_to project_pull_request_path(@status.id, :project_id => @project.id)}
|
||||
end
|
||||
|
@ -232,13 +236,15 @@ class PullRequestsController < ApplicationController
|
|||
request = @g.update_merge_request(@project.gpid, params[:id], User.current.gid, :state_event => params[:state])
|
||||
user = User.find_by_login(request.author.try(:username))
|
||||
status = params[:state] == "close" ? 4 : 3
|
||||
send_message_to_manager(@project.id, params[:id], status)
|
||||
# 更新所有管理员的消息为“已读”
|
||||
ForgeMessage.where(:forge_message_id => request.id, :project_id => @project.id, :forge_message_type => "PullRequest", :status => 1).update_all(:viewed => true)
|
||||
#send_message_to_manager(@project.id, params[:id], status)
|
||||
# 更新所有管理员的消息的
|
||||
ForgeMessage.where(:forge_message_id => request.id, :project_id => @project.id, :forge_message_type => "PullRequest").update_all(:status => status, :operate_user_id => User.current.id, :updated_at => Time.now)
|
||||
# 更新自己的消息为已读
|
||||
ForgeMessage.where(:forge_message_id => request.id, :project_id => @project.id, :forge_message_type => "PullRequest", :user_id => User.current.id).update_all(:viewed => true)
|
||||
# 更新pullrequest的status字段
|
||||
PullRequest.where(:pull_request_id => params[:id].to_i).update_all(:status => status)
|
||||
|
||||
if is_project_manager?(User.current.id, @project.id)
|
||||
# 给作者发送消息,如何已经发送了消息,则不发
|
||||
if is_project_manager?(User.current.id, @project.id) && ForgeMessage.where(:forge_message_id => request.id, :project_id => @project.id, :forge_message_type => "PullRequest", :user_id => user.id).count == 0
|
||||
send_message_to_author(@project.id, user.login, request.id, status)
|
||||
end
|
||||
respond_to do |format|
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -234,7 +234,7 @@
|
|||
|
||||
</li>
|
||||
</div>
|
||||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
<li class="homepageNewsTime fr"><%= time_tag(ma.updated_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -7,8 +7,8 @@
|
|||
<% unless (count == 0 || User.current != @user) %>
|
||||
<%= link_to "全部设为已读", user_path(User.current, :viewed => 'all'), :class => "fl mr10" %>
|
||||
<% end %>
|
||||
共 <span style="color: red;" class="fl"><%= @message_count %></span> 个消息
|
||||
</span>
|
||||
<span class="fl">共 <span style="color: red;"><%= @message_count %></span> 个消息</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="resources">
|
||||
<%= render :partial => 'users/new_user_message', :locals => { :message_alls => @message_alls } %>
|
||||
|
|
Loading…
Reference in New Issue