demarches-normaliennes/app/controllers/administrateurs/dossier_submitted_messages_controller.rb
Martin 85a588541b feat(dossier_submitted_message): add a new system to customize the standby page (/merci) after an user created his folder. this is a basic feature that will come with more options asap
wip(dossier_created_hook): add tile to administrateurs/procedure#show in order to crud dossier_created_hook

refactor(css.utilities): remove merge helpers.scss within utils.scss (same purpose). use scss each for spacer modifiers

refactor(dossiers/_merci.html): extract partial _merci so we can re-use it in preview of dossier_created_hook.

feat(wip): current progress
2022-02-25 14:01:18 +01:00

45 lines
1.7 KiB
Ruby

module Administrateurs
class DossierSubmittedMessagesController < AdministrateurController
before_action :retrieve_procedure
def edit
@dossier_submitted_message = build_dossier_submitted_message
end
def update
@dossier_submitted_message = build_dossier_submitted_message(dossier_submitted_message_params)
if @dossier_submitted_message.save
redirect_to admin_procedure_path(@procedure), flash: { notice: "Les informations de fin de dépot ont bien été sauvegardées." }
else
flash.alert = "Impossible de sauvegarder les informations de fin de dépot, veuillez ré-essayer."
render :edit, status: 400
end
end
def create
@dossier_submitted_message = build_dossier_submitted_message(dossier_submitted_message_params)
if @dossier_submitted_message.save
redirect_to admin_procedure_path(@procedure), flash: { notice: "Les informations de fin de dépot ont bien été sauvegardées." }
else
flash.alert = "Impossible de sauvegarder les informations de \"fin de dépot\", veuillez ré-essayer."
render :edit, status: 400
end
end
private
# for now, only works on active revision no matter the procedure_revision_policy
def build_dossier_submitted_message(attributes = {})
dossier_submitted_message = @procedure.active_revision.dossier_submitted_message || @procedure.active_revision.build_dossier_submitted_message(procedure_id: @procedure.id)
dossier_submitted_message.attributes = attributes unless attributes.empty?
dossier_submitted_message
end
def dossier_submitted_message_params
params.require(:dossier_submitted_message)
.permit(:message_on_submit_by_usager)
end
end
end