2015-10-24 18:46:33 +05:30
|
|
|
class Projects::VariablesController < Projects::ApplicationController
|
2016-04-02 18:10:28 +05:30
|
|
|
before_action :authorize_admin_build!
|
2015-10-24 18:46:33 +05:30
|
|
|
|
|
|
|
layout 'project_settings'
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
def index
|
|
|
|
@variable = Ci::Variable.new
|
|
|
|
end
|
|
|
|
|
2015-10-24 18:46:33 +05:30
|
|
|
def show
|
2016-06-02 11:05:42 +05:30
|
|
|
@variable = @project.variables.find(params[:id])
|
2015-10-24 18:46:33 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2016-06-02 11:05:42 +05:30
|
|
|
@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-10-24 18:46:33 +05:30
|
|
|
redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variables were successfully updated.'
|
|
|
|
else
|
2016-06-02 11:05:42 +05:30
|
|
|
render action: "index"
|
2015-10-24 18:46:33 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
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-10-24 18:46:33 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def project_params
|
2016-06-02 11:05:42 +05:30
|
|
|
params.require(:variable).permit([:id, :key, :value, :_destroy])
|
2015-10-24 18:46:33 +05:30
|
|
|
end
|
|
|
|
end
|