Pull reques登录提示(权限控制)

This commit is contained in:
huang 2016-08-25 10:04:51 +08:00
parent 799c451921
commit 69301a1120
4 changed files with 21 additions and 9 deletions

View File

@ -1,8 +1,10 @@
class PullRequestsController < ApplicationController
before_filter :authorize_logged
before_filter :find_project_and_repository
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new,
:update_pull_request, :pull_request_comments, :create_pull_request_comment]
layout "base_projects"
include PullRequestsHelper
include ApplicationHelper
@ -235,6 +237,13 @@ class PullRequestsController < ApplicationController
end
private
def authorize_logged
if !User.current.logged?
redirect_to signin_path
return
end
end
def connect_gitlab
@g = Gitlab.client
end

View File

@ -40,12 +40,12 @@
</div>
<% end %>
<% if allow_pull_request(@project) %>
<div class="subNav">
<%= link_to "Pull Requests", project_pull_requests_path(@project), :class => "f14 c_blue02" %>
<div class="subNav">
<%= link_to "Pull Requests", project_pull_requests_path(@project), :class => "f14 c_blue02" %>
<% if allow_pull_request(@project) %>
<%= link_to "+新建请求", new_project_pull_request_path(:project_id => @project.id), :class => "subnav_green" %>
</div>
<% end %>
<% end %>
</div>
<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %>
<% if visible_repository?(@project) %>

View File

@ -5,8 +5,10 @@
<div id="pull_request_show">
<div id="mergeShow" class="f14 fontGrey2 merge-show">
<span class="mr10 open-status"><%= get_state(@request.state) %></span><span class="mr10">合并请求</span> 由 <%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %> 于 <%= time_tag(@request.created_at) %> 前提交 · 最后编辑时间 <%= time_tag(@request.updated_at) %> 前
<% unless @request.state == "merged" %>
<%= link_to "#{@request.state == 'closed' ? '重新打开' : '关闭'}", update_pull_request_project_pull_request_path(@request.id, :project_id => @project.id, :state => @request.state =="closed" ? "reopen" : "close"), :class => "BlueCirBtn fr" %>
<% if User.current.login == @request.author.try(:username) || is_project_manager?(User.current.id, @project.id) %>
<% unless @request.state == "merged" %>
<%= link_to "#{@request.state == 'closed' ? '重新打开' : '关闭'}", update_pull_request_project_pull_request_path(@request.id, :project_id => @project.id, :state => @request.state =="closed" ? "reopen" : "close"), :class => "BlueCirBtn fr" %>
<% end %>
<% end %>
<div class="cl"></div>
</div>

View File

@ -3,8 +3,9 @@
<li class="active"><%= link_to "待处理<span class='project-number-dot'>#{@requests_opened_count}</span>".html_safe, project_pull_requests_path(:type => "1"), :remote => true %></li>
<li><%= link_to "已处理<span class='project-number-dot'>#{@requests_merged_count}</span>".html_safe, project_pull_requests_path(:type => "2"), :remote => true %></li>
<li><%= link_to "已关闭<span class='project-number-dot'>#{@requests_closed_count}</span>".html_safe, project_pull_requests_path(:type => "3"), :remote => true %></li>
<%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
<% if allow_pull_request(@project) %>
<%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
<% end %>
<div class="cl"></div>
</ul>
<div class="cl"></div>