2015-03-27 09:43:48 -04:00
|
|
|
class Admin::DeployKeysController < Admin::ApplicationController
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :deploy_keys, only: [:index]
|
2017-03-31 08:54:38 -04:00
|
|
|
before_action :deploy_key, only: [:destroy, :edit, :update]
|
2015-03-27 09:43:48 -04:00
|
|
|
|
|
|
|
def index
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
2015-04-03 06:22:44 -04:00
|
|
|
@deploy_key = deploy_keys.new
|
2015-03-27 09:43:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2017-03-31 08:54:38 -04:00
|
|
|
@deploy_key = deploy_keys.new(create_params.merge(user: current_user))
|
2015-03-27 09:43:48 -04:00
|
|
|
|
|
|
|
if @deploy_key.save
|
|
|
|
redirect_to admin_deploy_keys_path
|
|
|
|
else
|
2017-03-31 08:54:38 -04:00
|
|
|
render 'new'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
if deploy_key.update_attributes(update_params)
|
|
|
|
flash[:notice] = 'Deploy key was successfully updated.'
|
|
|
|
redirect_to admin_deploy_keys_path
|
|
|
|
else
|
|
|
|
render 'edit'
|
2015-03-27 09:43:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
deploy_key.destroy
|
|
|
|
|
|
|
|
respond_to do |format|
|
2017-06-06 18:45:16 -04:00
|
|
|
format.html { redirect_to admin_deploy_keys_path, status: 302 }
|
2015-03-27 09:43:48 -04:00
|
|
|
format.json { head :ok }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def deploy_key
|
2015-04-03 06:22:44 -04:00
|
|
|
@deploy_key ||= deploy_keys.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def deploy_keys
|
|
|
|
@deploy_keys ||= DeployKey.are_public
|
2015-03-27 09:43:48 -04:00
|
|
|
end
|
|
|
|
|
2017-03-31 08:54:38 -04:00
|
|
|
def create_params
|
2016-11-22 03:06:42 -05:00
|
|
|
params.require(:deploy_key).permit(:key, :title, :can_push)
|
2015-03-27 09:43:48 -04:00
|
|
|
end
|
2017-03-31 08:54:38 -04:00
|
|
|
|
|
|
|
def update_params
|
|
|
|
params.require(:deploy_key).permit(:title, :can_push)
|
|
|
|
end
|
2015-03-27 09:43:48 -04:00
|
|
|
end
|