2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
class Projects::RunnerProjectsController < Projects::ApplicationController
|
2016-04-02 18:10:28 +05:30
|
|
|
before_action :authorize_admin_build!
|
2015-12-23 02:04:40 +05:30
|
|
|
|
|
|
|
layout 'project_settings'
|
|
|
|
|
|
|
|
def create
|
|
|
|
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
return head(403) unless can?(current_user, :assign_runner, @runner)
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
path = project_runners_path(project)
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
if @runner.assign_to(project, current_user)
|
2015-12-23 02:04:40 +05:30
|
|
|
redirect_to path
|
|
|
|
else
|
|
|
|
redirect_to path, alert: 'Failed adding runner to project'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
runner_project = project.runner_projects.find(params[:id])
|
|
|
|
runner_project.destroy
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
redirect_to project_runners_path(project), status: :found
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
|
|
|
end
|