[refs #90] fixed pull abilities part 2
This commit is contained in:
parent
496cb7d354
commit
cc05fa695a
|
@ -4,8 +4,8 @@ class Projects::PullRequestsController < Projects::BaseController
|
|||
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
|
||||
load_resource :project
|
||||
|
||||
load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id, :parent => false, :except => [:autocomplete_base_project, :index]
|
||||
load_resource :instance_name => :pull, :through => :issue, :singleton => true, :except => [:index]
|
||||
load_resource :issue, :through => :project, :find_by => :serial_id, :parent => false, :except => [:index, :autocomplete_base_project]
|
||||
load_and_authorize_resource :instance_name => :pull, :through => :issue, :singleton => true, :except => [:index, :autocomplete_base_project]
|
||||
|
||||
def new
|
||||
base_project = (Project.find(params[:base_project_id]) if params[:base_project_id]) || @project.root
|
||||
|
@ -110,7 +110,6 @@ class Projects::PullRequestsController < Projects::BaseController
|
|||
end
|
||||
|
||||
def autocomplete_base_project
|
||||
#Maybe slow? ILIKE?
|
||||
items = Project.accessible_by(current_ability, :membered).search(params[:term])
|
||||
items = items | [@project.root]
|
||||
items.select! {|e| Regexp.new(params[:term].downcase).match(e.name.downcase) && e.repo.branches.count > 0}
|
||||
|
|
|
@ -116,11 +116,17 @@ class Ability
|
|||
|
||||
can :read, Issue, :project => {:owner_type => 'User', :owner_id => user.id}
|
||||
can :read, Issue, :project => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||
can([:read, :autocomplete_base_project], Issue, read_relations_for('issues', 'projects')) {|issue| can? :read, issue.project rescue nil}
|
||||
can(:merge, Issue) {|issue| can? :write, issue.project}
|
||||
can(:read, Issue, read_relations_for('issues', 'projects')) {|issue| can? :read, issue.project rescue nil}
|
||||
can(:create, Issue) {|issue| can? :read, issue.project}
|
||||
can([:update, :destroy], Issue) {|issue| issue.user_id == user.id or local_admin?(issue.project)}
|
||||
cannot(:manage, Issue) {|issue| !issue.pull_request && !issue.project.has_issues? } # switch off issues
|
||||
cannot :manage, Issue, :project => {:has_issues => false} # switch off issues
|
||||
|
||||
can :read, PullRequest, :project => {:owner_type => 'User', :owner_id => user.id}
|
||||
can :read, PullRequest, :project => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||
can(:read, PullRequest, read_relations_for('pull_requests', 'base_projects')) {|pull| can? :read, pull.base_project rescue nil}
|
||||
can(:merge, PullRequest) {|pull| can? :write, pull.base_project}
|
||||
can :create, PullRequest
|
||||
can([:update, :destroy], PullRequest) {|pull| pull.user_id == user.id or local_admin?(pull.base_project)}
|
||||
|
||||
can(:create, Comment) {|comment| can? :read, comment.project}
|
||||
can(:update, Comment) {|comment| comment.user == user or comment.project.owner == user or local_admin?(comment.project)}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- if can?(:merge, @issue) && @pull.can_merging?
|
||||
- if can?(:merge, @pull) && @pull.can_merging?
|
||||
%br
|
||||
=form_for PullRequest.new, :url => merge_project_pull_request_path(@project, @pull), :html => { :method => :put, :class => :form } do |f|
|
||||
=f.submit t 'projects.pull_requests.ready'
|
||||
|
@ -6,7 +6,7 @@
|
|||
.flash
|
||||
%div{:class => @pull.ready? ? 'notice' : 'alert'}
|
||||
=pull_status @pull
|
||||
-if can? :update, @pull.issue
|
||||
-if can? :update, @pull
|
||||
-if action = @pull.can_close? ? 'close' : ('reopen' if @pull.can_reopen?)
|
||||
%br
|
||||
=form_for :pull, :url => [@project, @pull], :html => { :id => 'do_pull_action',:method => :put, :class => :form } do |f|
|
||||
|
|
Loading…
Reference in New Issue