2016-01-20 15:48:46 +01:00
|
|
|
class API::V1::DossiersController < APIController
|
|
|
|
|
|
|
|
def index
|
|
|
|
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
2016-01-21 11:41:24 +01:00
|
|
|
dossiers = procedure.dossiers.paginate(page: params[:page])
|
|
|
|
render json: dossiers, each_serializer: DossiersSerializer, meta: pagination(dossiers), meta_key: 'pagination', status: 200
|
2016-01-20 15:48:46 +01:00
|
|
|
rescue ActiveRecord::RecordNotFound => e
|
|
|
|
render json: {}, status: 404
|
|
|
|
end
|
|
|
|
|
2016-01-25 16:08:10 +01:00
|
|
|
def show
|
|
|
|
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
|
|
|
dossier = procedure.dossiers.find(params[:id])
|
|
|
|
render json: dossier, status: 200
|
|
|
|
rescue ActiveRecord::RecordNotFound => e
|
|
|
|
render json: {}, status: 404
|
|
|
|
end
|
|
|
|
|
|
|
|
def pagination(dossiers)
|
2016-01-20 15:48:46 +01:00
|
|
|
{
|
|
|
|
page: dossiers.current_page,
|
|
|
|
resultats_par_page: dossiers.per_page,
|
|
|
|
nombre_de_page: dossiers.total_pages
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|