gitlab-org--gitlab-foss/app/controllers/projects/protected_branches_controller.rb

52 lines
1.4 KiB
Ruby
Raw Normal View History

class Projects::ProtectedBranchesController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
before_action :authorize_admin_project!
layout "project_settings"
2012-02-15 16:51:04 -05:00
def index
2013-12-25 09:12:25 -05:00
@branches = @project.protected_branches.to_a
@protected_branch = @project.protected_branches.new
end
def create
@project.protected_branches.create(protected_branch_params)
redirect_to namespace_project_protected_branches_path(@project.namespace,
@project)
end
def update
protected_branch = @project.protected_branches.find(params[:id])
if protected_branch &&
protected_branch.update_attributes(
2015-12-14 21:53:52 -05:00
developers_can_push: params[:developers_can_push]
)
2014-12-26 09:37:04 -05:00
respond_to do |format|
2015-01-23 20:41:10 -05:00
format.json { render json: protected_branch, status: :ok }
2014-12-26 09:37:04 -05:00
end
else
respond_to do |format|
format.json { render json: protected_branch.errors, status: :unprocessable_entity }
end
end
end
def destroy
2012-02-15 16:51:04 -05:00
@project.protected_branches.find(params[:id]).destroy
respond_to do |format|
format.html { redirect_to namespace_project_protected_branches_path }
format.js { render nothing: true }
2012-02-15 16:51:04 -05:00
end
end
private
def protected_branch_params
params.require(:protected_branch).permit(:name, :developers_can_push)
end
end