2017-12-28 19:44:11 +01:00
|
|
|
module Manager
|
|
|
|
class ProceduresController < Manager::ApplicationController
|
2019-10-31 16:30:39 +01: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?
|
|
|
|
# Don't display deleted dossiers in the unfiltered list…
|
|
|
|
Procedure
|
|
|
|
else
|
|
|
|
# … but allow them to be searched and displayed.
|
|
|
|
Procedure.unscope(:where)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-10 16:46:12 +01:00
|
|
|
def whitelist
|
|
|
|
procedure.whitelist!
|
2018-09-05 14:48:42 +02:00
|
|
|
flash[:notice] = "Démarche whitelistée."
|
2018-01-10 16:46:12 +01:00
|
|
|
redirect_to manager_procedure_path(procedure)
|
|
|
|
end
|
2018-10-09 12:11:13 +02:00
|
|
|
|
|
|
|
def draft
|
|
|
|
if procedure.dossiers.empty?
|
|
|
|
procedure.draft!
|
|
|
|
flash[:notice] = "La démarche a bien été passée en brouillon."
|
|
|
|
else
|
|
|
|
flash[:alert] = "Impossible de repasser en brouillon une démarche à laquelle sont rattachés des dossiers."
|
|
|
|
end
|
|
|
|
redirect_to manager_procedure_path(procedure)
|
|
|
|
end
|
2018-11-20 17:38:04 +01:00
|
|
|
|
|
|
|
def hide
|
|
|
|
procedure.hide!
|
|
|
|
flash[:notice] = "La démarche a bien été supprimée, en cas d'erreur contactez un développeur."
|
2018-11-22 00:02:01 +01:00
|
|
|
redirect_to manager_procedures_path
|
2018-11-20 17:38:04 +01:00
|
|
|
end
|
2019-02-27 14:42:21 +01:00
|
|
|
|
|
|
|
def add_administrateur
|
|
|
|
administrateur = Administrateur.find_by(email: params[:email])
|
|
|
|
if administrateur
|
|
|
|
procedure.administrateurs << administrateur
|
|
|
|
flash[:notice] = "L'administrateur \"#{params[:email]}\" est ajouté à la démarche."
|
|
|
|
else
|
|
|
|
flash[:alert] = "L'administrateur \"#{params[:email]}\" est introuvable."
|
|
|
|
end
|
|
|
|
redirect_to manager_procedure_path(procedure)
|
|
|
|
end
|
2019-04-17 16:33:24 +02:00
|
|
|
|
2019-04-17 16:36:57 +02:00
|
|
|
def change_piece_justificative_template
|
|
|
|
if type_de_champ.update(type_de_champ_params)
|
|
|
|
flash[:notice] = "Le modèle est mis à jour."
|
|
|
|
else
|
|
|
|
flash[:alert] = type_de_champ.errors.full_messages.join(', ')
|
|
|
|
end
|
|
|
|
redirect_to manager_procedure_path(procedure)
|
|
|
|
end
|
|
|
|
|
2019-04-17 16:33:24 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def procedure
|
|
|
|
Procedure.find(params[:id])
|
|
|
|
end
|
2019-04-17 16:36:57 +02:00
|
|
|
|
|
|
|
def type_de_champ
|
|
|
|
TypeDeChamp.find(params[:type_de_champ][:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def type_de_champ_params
|
|
|
|
params.require(:type_de_champ).permit(:piece_justificative_template)
|
|
|
|
end
|
2019-10-31 16:30:39 +01:00
|
|
|
|
|
|
|
def unfiltered_list?
|
|
|
|
action_name == "index" && !params[:search]
|
|
|
|
end
|
2017-12-28 19:44:11 +01:00
|
|
|
end
|
|
|
|
end
|