a8354bd103
The code paths for deleting a dossier were different, depending on whether the dossier was deleted by the user, or from the Manager. This commit unifies the two code paths into one. This has the effect of: - An operation log is now recorded when an user deletes its own dossier; - Gestionnaires are now notified even when the dossier is deleted from the Manager; - The `support:delete_user_account` task now requires the email address of the author.
39 lines
989 B
Ruby
39 lines
989 B
Ruby
module Manager
|
|
class DossiersController < Manager::ApplicationController
|
|
#
|
|
# 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…
|
|
Dossier
|
|
else
|
|
# … but allow them to be searched and displayed.
|
|
Dossier.unscope(:where)
|
|
end
|
|
end
|
|
|
|
#
|
|
# Custom actions
|
|
#
|
|
|
|
def hide
|
|
dossier = Dossier.find(params[:id])
|
|
dossier.delete_and_keep_track(current_administration)
|
|
|
|
logger.info("Le dossier #{dossier.id} est supprimé par #{current_administration.email}")
|
|
flash[:notice] = "Le dossier #{dossier.id} a été supprimé."
|
|
|
|
redirect_to manager_dossier_path(dossier)
|
|
end
|
|
|
|
private
|
|
|
|
def unfiltered_list?
|
|
action_name == "index" && !params[:search]
|
|
end
|
|
end
|
|
end
|