2015-11-16 16:16:08 +01:00
|
|
|
class Admin::PiecesJustificativesController < AdminController
|
2015-11-20 13:54:08 +01:00
|
|
|
before_action :retrieve_procedure
|
2015-11-16 16:16:08 +01:00
|
|
|
|
2015-11-20 13:54:08 +01:00
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@procedure.update_attributes(update_params)
|
|
|
|
render 'show', format: :js
|
|
|
|
end
|
|
|
|
|
2015-11-20 15:12:47 +01:00
|
|
|
def destroy
|
|
|
|
@procedure.types_de_piece_justificative.find(params[:id]).destroy
|
|
|
|
|
|
|
|
render 'show', format: :js
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
render json: { message: 'Type de piece justificative not found' }, status: 404
|
|
|
|
end
|
|
|
|
|
2015-11-20 13:54:08 +01:00
|
|
|
def update_params
|
|
|
|
params
|
|
|
|
.require(:procedure)
|
|
|
|
.permit(types_de_piece_justificative_attributes: [:libelle, :description, :id])
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def retrieve_procedure
|
|
|
|
@procedure = current_administrateur.procedures.find(params[:procedure_id])
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
render json: { message: 'Procedure not found' }, status: 404
|
2015-11-16 16:16:08 +01:00
|
|
|
end
|
|
|
|
end
|