debian-mirror-gitlab/app/controllers/ci/runner_projects_controller.rb

37 lines
872 B
Ruby
Raw Normal View History

2015-09-25 12:07:36 +05:30
module Ci
class RunnerProjectsController < Ci::ApplicationController
before_action :authenticate_user!
before_action :project
before_action :authorize_manage_project!
layout 'ci/project'
def create
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
return head(403) unless current_user.ci_authorized_runners.include?(@runner)
2015-10-24 18:46:33 +05:30
path = runners_path(@project.gl_project)
2015-09-25 12:07:36 +05:30
if @runner.assign_to(project, current_user)
2015-10-24 18:46:33 +05:30
redirect_to path
2015-09-25 12:07:36 +05:30
else
2015-10-24 18:46:33 +05:30
redirect_to path, alert: 'Failed adding runner to project'
2015-09-25 12:07:36 +05:30
end
end
def destroy
runner_project = project.runner_projects.find(params[:id])
runner_project.destroy
2015-10-24 18:46:33 +05:30
redirect_to runners_path(@project.gl_project)
2015-09-25 12:07:36 +05:30
end
private
def project
@project ||= Ci::Project.find(params[:project_id])
end
end
end