2018-05-31 15:18:06 +02:00
|
|
|
module Manager
|
|
|
|
class DossiersController < Manager::ApplicationController
|
2018-07-23 13:02:25 +02:00
|
|
|
#
|
|
|
|
# Administrate overrides
|
|
|
|
#
|
|
|
|
|
|
|
|
# Override this if you have certain roles that require a subset
|
|
|
|
# this will be used to set the records shown on the `index` action.
|
|
|
|
def scoped_resource
|
|
|
|
if unfiltered_list?
|
2020-03-25 18:08:32 +01:00
|
|
|
# Don't display discarded dossiers in the unfiltered list…
|
|
|
|
Dossier.kept
|
2018-07-23 13:02:25 +02:00
|
|
|
else
|
|
|
|
# … but allow them to be searched and displayed.
|
2020-03-25 18:08:32 +01:00
|
|
|
Dossier.with_discarded
|
2018-07-23 13:02:25 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Custom actions
|
|
|
|
#
|
|
|
|
|
2020-03-25 18:08:32 +01:00
|
|
|
def discard
|
2019-02-13 16:13:37 +01:00
|
|
|
dossier = Dossier.find(params[:id])
|
2020-11-05 15:09:11 +01:00
|
|
|
dossier.discard_and_keep_track!(current_super_admin, :manager_request)
|
2019-02-13 16:13:37 +01:00
|
|
|
|
2020-11-05 15:09:11 +01:00
|
|
|
logger.info("Le dossier #{dossier.id} est supprimé par #{current_super_admin.email}")
|
2019-07-15 16:00:49 +02:00
|
|
|
flash[:notice] = "Le dossier #{dossier.id} a été supprimé."
|
2019-02-13 16:13:37 +01:00
|
|
|
|
|
|
|
redirect_to manager_dossier_path(dossier)
|
|
|
|
end
|
|
|
|
|
2020-03-26 17:35:50 +01:00
|
|
|
def restore
|
|
|
|
dossier = Dossier.with_discarded.find(params[:id])
|
2020-11-05 15:09:11 +01:00
|
|
|
dossier.restore(current_super_admin)
|
2020-03-26 17:35:50 +01:00
|
|
|
|
|
|
|
flash[:notice] = "Le dossier #{dossier.id} a été restauré."
|
|
|
|
|
|
|
|
redirect_to manager_dossier_path(dossier)
|
|
|
|
end
|
|
|
|
|
2019-07-29 10:57:21 +02:00
|
|
|
def repasser_en_instruction
|
|
|
|
dossier = Dossier.find(params[:id])
|
2021-11-26 12:19:40 +01:00
|
|
|
dossier.repasser_en_instruction(instructeur: current_super_admin)
|
2019-07-29 10:57:21 +02:00
|
|
|
|
2020-11-05 15:09:11 +01:00
|
|
|
logger.info("Le dossier #{dossier.id} est repassé en instruction par #{current_super_admin.email}")
|
2019-07-29 10:57:21 +02:00
|
|
|
flash[:notice] = "Le dossier #{dossier.id} est repassé en instruction."
|
|
|
|
|
|
|
|
redirect_to manager_dossier_path(dossier)
|
|
|
|
end
|
|
|
|
|
2018-07-23 13:02:25 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def unfiltered_list?
|
|
|
|
action_name == "index" && !params[:search]
|
|
|
|
end
|
2018-05-31 15:18:06 +02:00
|
|
|
end
|
|
|
|
end
|