接受请求后显示admin问题

This commit is contained in:
huang 2016-08-05 20:14:19 +08:00
parent 2bdf3d573b
commit ecc6f5601e
3 changed files with 23 additions and 5 deletions

View File

@ -98,7 +98,7 @@ class PullRequestsController < ApplicationController
# @return [Gitlab::ObjectifiedHash] # @return [Gitlab::ObjectifiedHash]
def accept_pull_request def accept_pull_request
begin begin
status = @g.accept_merge_rquest(@project.gpid, params[:id]) status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
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)}
end end

View File

@ -9,11 +9,11 @@
</div> </div>
<div class="new-merge-wrap borderBottomNone"> <div class="new-merge-wrap borderBottomNone">
<div class="merge-option-name fl" style="padding:5px 0">源分支</div> <div class="merge-option-name fl" style="padding:5px 0">源分支</div>
<%= select_tag :branch, options_for_select(@source_rev), :name => "source_branch", :value => "source_branch", :class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;" %> <%= select_tag :branch, options_for_select(@source_rev), :id => "source_branch", :name => "source_branch", :value => "source_branch", :class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;" %>
<div class="cl mb10"></div> <div class="cl mb10"></div>
<div class="merge-option-name fl" style="padding:5px 0">目标分支</div> <div class="merge-option-name fl" style="padding:5px 0">目标分支</div>
<% if @forked_project.nil? %> <% if @forked_project.nil? %>
<%= select_tag :branch, options_for_select(@source_rev), :name => "target_branch", :value => "target_branch",:class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetBranch" %> <%= select_tag :branch, options_for_select(@source_rev), :id => "pull_request_branch", :name => "target_branch", :value => "target_branch",:class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;" %>
<% else %> <% else %>
<select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" name="source_project" value="source_project" class="ml30 fontGrey3 fb fl" style = "padding:5px 0 5px 5px;"> <select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" name="source_project" value="source_project" class="ml30 fontGrey3 fb fl" style = "padding:5px 0 5px 5px;">
<option value="source_project_name"><%= @source_project_name %></option> <option value="source_project_name"><%= @source_project_name %></option>
@ -26,6 +26,8 @@
</select> </select>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
<p id ="pull_request_branch_error" class="ml100 fontGrey2 mt5 c_red" style="display: none">同一个项目的源分支和目标分支不能相同</p>
<div class="cl"></div>
</div> </div>
<div class="new-merge-row b_grey" style="border-top:1px solid #ddd;"> <div class="new-merge-row b_grey" style="border-top:1px solid #ddd;">
<a href="javascript:void(0);" class="BlueCirBtn fl ml10" onclick="pull_request_commit()">提交请求</a> <a href="javascript:void(0);" class="BlueCirBtn fl ml10" onclick="pull_request_commit()">提交请求</a>
@ -50,6 +52,22 @@
} }
} }
function regex_branch()
{
var source_branch = $.trim($("#source_branch").val());
var target_branch = $.trim($("#pull_request_branch").val());
if(source_branch == target_branch)
{
$("#pull_request_branch_error").show();
return false;
}
else
{
$("#pull_request_branch_error").hide();
return true;
}
}
//提交pull request //提交pull request
function pull_request_commit() function pull_request_commit()
{ {

View File

@ -118,8 +118,8 @@ class Gitlab::Client
# @param [Integer] project The ID of a project. # @param [Integer] project The ID of a project.
# @param [Integer] id The ID of a merge request. # @param [Integer] id The ID of a merge request.
# @return [Gitlab::ObjectifiedHash] # @return [Gitlab::ObjectifiedHash]
def accept_merge_rquest(project, id) def accept_merge_rquest(project, id, gid)
put("/projects/#{project}/merge_request/#{id}/merge") put("/projects/#{project}/merge_request/#{id}/merge?user_id=#{gid}")
end end
private private