From 4ab5d300449f689d9313b01a788da36994cb9f7c Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 4 Jul 2018 11:49:24 +0200 Subject: [PATCH] dossiers: move the index method to the top of the controller --- .../new_user/dossiers_controller.rb | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb index df860054b..971c471dd 100644 --- a/app/controllers/new_user/dossiers_controller.rb +++ b/app/controllers/new_user/dossiers_controller.rb @@ -7,6 +7,20 @@ module NewUser before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update] before_action :forbid_invite_submission!, only: [:update] + def index + @user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page) + @dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page) + + @current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count) + + @dossiers = case @current_tab + when 'mes-dossiers' + @user_dossiers + when 'dossiers-invites' + @dossiers_invites + end + end + def attestation send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf') end @@ -87,20 +101,6 @@ module NewUser @dossier = current_user.dossiers.includes(:procedure).find(params[:id]) end - def index - @user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page) - @dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page) - - @current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count) - - @dossiers = case @current_tab - when 'mes-dossiers' - @user_dossiers - when 'dossiers-invites' - @dossiers_invites - end - end - def ask_deletion dossier = current_user.dossiers.includes(:user, procedure: :administrateur).find(params[:id])