2015-11-16 16:16:08 +01:00
|
|
|
class Admin::ProceduresController < AdminController
|
2015-10-26 15:54:20 +01:00
|
|
|
|
|
|
|
def index
|
2015-11-10 11:58:56 +01:00
|
|
|
@procedures = current_administrateur.procedures
|
2015-10-26 15:54:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@procedure = Procedure.find(params[:id])
|
2015-11-09 17:15:51 +01:00
|
|
|
@types_de_champ = @procedure.types_de_champ.order(:order_place)
|
|
|
|
@types_de_piece_justificative = @procedure.types_de_piece_justificative.order(:libelle)
|
|
|
|
|
2015-10-26 15:54:20 +01:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
flash.alert = 'Procédure inéxistante'
|
|
|
|
redirect_to admin_procedures_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@procedure ||= Procedure.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2015-11-04 17:27:01 +01:00
|
|
|
@procedure = Procedure.new(create_procedure_params)
|
2015-10-26 15:54:20 +01:00
|
|
|
|
|
|
|
unless @procedure.save
|
|
|
|
flash.now.alert = @procedure.errors.full_messages.join('<br />').html_safe
|
|
|
|
return render 'new'
|
|
|
|
end
|
|
|
|
|
|
|
|
flash.notice = 'Procédure enregistrée'
|
|
|
|
redirect_to admin_procedures_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2015-11-16 16:16:08 +01:00
|
|
|
|
2015-10-26 15:54:20 +01:00
|
|
|
@procedure = Procedure.find(params[:id])
|
|
|
|
|
2015-10-29 17:22:57 +01:00
|
|
|
unless @procedure.update_attributes(create_procedure_params)
|
2015-10-26 15:54:20 +01:00
|
|
|
flash.now.alert = @procedure.errors.full_messages.join('<br />').html_safe
|
|
|
|
return render 'show'
|
|
|
|
end
|
|
|
|
flash.notice = 'Préocédure modifiée'
|
|
|
|
redirect_to admin_procedures_path
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-10-29 17:22:57 +01:00
|
|
|
def create_procedure_params
|
2015-10-26 15:54:20 +01:00
|
|
|
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :use_api_carto)
|
|
|
|
end
|
|
|
|
end
|