Commit 24eed1c5 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Modify runner projects selecting method in runners API

parent 36e7ffea
...@@ -387,12 +387,12 @@ module API ...@@ -387,12 +387,12 @@ module API
expose :tag_list expose :tag_list
expose :version, :revision, :platform, :architecture expose :version, :revision, :platform, :architecture
expose :contacted_at, as: :last_contact expose :contacted_at, as: :last_contact
expose :token, if: lambda { |runner, options| options[:user_is_admin] || !runner.is_shared? } expose :token, if: lambda { |runner, options| options[:current_user].is_admin? || !runner.is_shared? }
expose :projects, with: Entities::RunnerProjectDetails do |runner, options| expose :projects, with: Entities::RunnerProjectDetails do |runner, options|
if options[:user_is_admin] if options[:current_user].is_admin?
runner.projects runner.projects
else else
runner.projects.where(id: options[:available_projects_ids]) options[:current_user].authorized_projects.where(id: runner.projects)
end end
end end
end end
......
...@@ -33,11 +33,7 @@ module API ...@@ -33,11 +33,7 @@ module API
runner = get_runner(params[:id]) runner = get_runner(params[:id])
authenticate_show_runner!(runner) authenticate_show_runner!(runner)
available_projects_ids = runner.projects.select{ |p| can?(current_user, :read_project, p) } present runner, with: Entities::RunnerDetails, current_user: current_user
.map(&:id) unless current_user.is_admin?
present runner, with: Entities::RunnerDetails, user_is_admin: current_user.is_admin?,
available_projects_ids: available_projects_ids
end end
# Update runner's details # Update runner's details
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment