2015-09-28 11:19:20 -04:00
|
|
|
class Projects::VariablesController < Projects::ApplicationController
|
2016-02-01 17:58:04 -05:00
|
|
|
before_action :authorize_admin_build!
|
2015-09-28 11:19:20 -04:00
|
|
|
|
|
|
|
layout 'project_settings'
|
|
|
|
|
2016-04-27 04:01:43 -04:00
|
|
|
def index
|
|
|
|
@variable = Ci::Variable.new
|
|
|
|
end
|
|
|
|
|
2015-09-28 11:19:20 -04:00
|
|
|
def show
|
2016-04-27 04:01:43 -04:00
|
|
|
@variable = @project.variables.find(params[:id])
|
2015-09-28 11:19:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2016-04-27 04:01:43 -04:00
|
|
|
@variable = @project.variables.find(params[:id])
|
|
|
|
|
|
|
|
if @variable.update_attributes(project_params)
|
|
|
|
redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variable was successfully updated.'
|
|
|
|
else
|
|
|
|
render action: "show"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@variable = Ci::Variable.new(project_params)
|
|
|
|
|
|
|
|
if @variable.valid? && @project.variables << @variable
|
2015-09-28 11:19:20 -04:00
|
|
|
redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variables were successfully updated.'
|
|
|
|
else
|
2016-04-27 04:01:43 -04:00
|
|
|
render action: "index"
|
2015-09-28 11:19:20 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-27 04:01:43 -04:00
|
|
|
def destroy
|
|
|
|
@key = @project.variables.find(params[:id])
|
|
|
|
@key.destroy
|
|
|
|
|
|
|
|
redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variable was successfully removed.'
|
|
|
|
end
|
|
|
|
|
2015-09-28 11:19:20 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def project_params
|
2016-04-27 04:01:43 -04:00
|
|
|
params.require(:variable).permit([:id, :key, :value, :_destroy])
|
2015-09-28 11:19:20 -04:00
|
|
|
end
|
|
|
|
end
|