From 21a2a5402b1f4709bc77df494727a2bd7adef583 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 20 Apr 2017 10:55:54 +0200 Subject: [PATCH] Remove unused service --- app/controllers/users/dossiers_controller.rb | 6 +-- app/facades/dossiers_list_facades.rb | 14 +------ app/models/dossier.rb | 1 + app/services/dossiers_list_user_service.rb | 43 -------------------- 4 files changed, 3 insertions(+), 61 deletions(-) delete mode 100644 app/services/dossiers_list_user_service.rb diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 6edec7153..313037fed 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -10,7 +10,7 @@ class Users::DossiersController < UsersController end def index - set_liste + @liste ||= params[:liste] || 'a_traiter' @user_dossiers = current_user.dossiers @@ -232,8 +232,4 @@ class Users::DossiersController < UsersController def facade id = params[:id] DossierFacades.new id, current_user.email end - - def set_liste - @liste ||= params[:liste] || 'a_traiter' - end end diff --git a/app/facades/dossiers_list_facades.rb b/app/facades/dossiers_list_facades.rb index 63b7dc60c..016d007d8 100644 --- a/app/facades/dossiers_list_facades.rb +++ b/app/facades/dossiers_list_facades.rb @@ -10,11 +10,7 @@ class DossiersListFacades end def service - if gestionnaire? - @service ||= DossiersListGestionnaireService.new @current_devise_profil, @liste, @procedure - elsif user? - @service ||= DossiersListUserService.new @current_devise_profil, @liste - end + @service ||= DossiersListGestionnaireService.new @current_devise_profil, @liste, @procedure end def total_dossier @@ -81,14 +77,6 @@ class DossiersListFacades private - def gestionnaire? - @current_devise_profil.class == Gestionnaire - end - - def user? - @current_devise_profil.class == User - end - def base_url liste @procedure.nil? ? backoffice_dossiers_path(liste: liste) : backoffice_dossiers_procedure_path(id: @procedure.id, liste: liste) end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 731320a5f..f22deacda 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -200,6 +200,7 @@ class Dossier < ActiveRecord::Base end scope :archived, -> { where(archived: true) } + scope :not_archived, -> { where(archived: false) } scope :downloadable, -> { all_state } diff --git a/app/services/dossiers_list_user_service.rb b/app/services/dossiers_list_user_service.rb deleted file mode 100644 index 24ec93b0f..000000000 --- a/app/services/dossiers_list_user_service.rb +++ /dev/null @@ -1,43 +0,0 @@ -class DossiersListUserService - def initialize current_devise_profil, liste - @current_devise_profil = current_devise_profil - @liste = liste - end - - def dossiers_to_display - {'brouillon' => brouillon, - 'a_traiter' => en_construction, - 'en_instruction' => en_instruction, - 'termine' => termine, - 'invite' => invite, - 'all_state' => all_state}[@liste] - end - - def self.dossiers_liste_libelle - ['brouillon', 'a_traiter', 'en_instruction', 'termine', 'invite', 'all_state'] - end - - def all_state - @all_state ||= @current_devise_profil.dossiers.all_state - end - - def brouillon - @brouillon ||= @current_devise_profil.dossiers.brouillon - end - - def en_construction - @en_construction ||= @current_devise_profil.dossiers.en_construction - end - - def invite - @invite ||= @current_devise_profil.invites - end - - def en_instruction - @en_instruction ||= @current_devise_profil.dossiers.en_instruction - end - - def termine - @termine ||= @current_devise_profil.dossiers.termine - end -end