#219: small refactoring of API::Issues controller, fixed ability.rb

This commit is contained in:
Vokhmin Alexey V 2013-07-17 17:53:14 +04:00
parent 23ce992a3d
commit d3040c4074
2 changed files with 5 additions and 5 deletions

View File

@ -16,13 +16,13 @@ class Api::V1::IssuesController < Api::V1::BaseController
def all_index def all_index
project_ids = get_all_project_ids Project.accessible_by(current_ability, :membered).pluck(:id) project_ids = get_all_project_ids Project.accessible_by(current_ability, :membered).pluck(:id)
@issues = Issue.where('issues.project_id IN (?)', project_ids) @issues = Issue.where(:project_id => project_ids)
render_issues_list render_issues_list
end end
def user_index def user_index
project_ids = get_all_project_ids current_user.projects.pluck(:id) project_ids = get_all_project_ids current_user.projects.pluck(:id)
@issues = Issue.where('issues.project_id IN (?)', project_ids) @issues = Issue.where(:project_id => project_ids)
render_issues_list render_issues_list
end end

View File

@ -61,9 +61,9 @@ class Ability
can :create, Project can :create, Project
can :read, Project, :visibility => 'open' can :read, Project, :visibility => 'open'
can [:read, :archive], Project, :owner_type => 'User', :owner_id => user.id can [:read, :archive, :membered, :get_id], Project, :owner_type => 'User', :owner_id => user.id
can [:read, :archive], Project, :owner_type => 'Group', :owner_id => user.group_ids can [:read, :archive, :membered, :get_id], Project, :owner_type => 'Group', :owner_id => user.group_ids
can([:read, :membered, :get_id], Project, read_relations_for('projects')) {|project| local_reader? project} can([:read, :archive, :membered, :get_id], Project, read_relations_for('projects')) {|project| local_reader? project}
can(:write, Project) {|project| local_writer? project} # for grack can(:write, Project) {|project| local_writer? project} # for grack
can [:update, :sections, :manage_collaborators, :autocomplete_maintainers, :add_member, :remove_member, :update_member, :members], Project do |project| can [:update, :sections, :manage_collaborators, :autocomplete_maintainers, :add_member, :remove_member, :update_member, :members], Project do |project|
local_admin? project local_admin? project