demarches-normaliennes/app/controllers/instructeurs/archives_controller.rb
Martin 3737311390 feat(procedure.procedure_expires_when_termine_enabled): enable by default, allow contributor to choose the default settings of this flag using an env var during migration. ie: DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED=true|false
feat(administrateurs/procedures#show): warning/alert when procedure_expires_when_termine_enabled is not true on current procedure

feat(administrateur/procedure#update): after an update redirect to procedure show: suggested by: https://ux.stackexchange.com/questions/55291/after-updating-form-should-redirect-back-to-form-itself-or-to-the-show-page-or-b and confirmed by Olivier

clean(Flipper.archive_zip_globale): no more in use, so remove all occurences

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update spec/views/administrateurs/procedures/show.html.haml_spec.rb

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

fix(review): typo, why ena?, who knows

fix(env.example.optional): add missing DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED
2022-05-05 13:07:11 +02:00

55 lines
1.7 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module Instructeurs
class ArchivesController < InstructeurController
before_action :ensure_procedure_enabled, only: [:create]
def index
@procedure = procedure
@average_dossier_weight = procedure.average_dossier_weight
@count_dossiers_termines_by_month = Traitement.count_dossiers_termines_by_month(groupe_instructeurs)
@archives = Archive
.for_groupe_instructeur(groupe_instructeurs)
.to_a
end
def create
type = params[:type]
month = Date.strptime(params[:month], '%Y-%m') if params[:month].present?
archive = ProcedureArchiveService.new(procedure).create_pending_archive(current_instructeur, type, month)
if archive.pending?
ArchiveCreationJob.perform_later(procedure, archive, current_instructeur)
flash[:notice] = "Votre demande a été prise en compte. Selon le nombre de dossiers, cela peut prendre quelques minutes. Vous recevrez un courriel lorsque le fichier sera disponible."
else
flash[:notice] = "Cette archive a déjà été générée."
end
redirect_to instructeur_archives_path(procedure)
end
private
def ensure_procedure_enabled
if procedure.brouillon?
flash[:alert] = "L'accès aux archives nest pas disponible pour cette démarche, merci den faire la demande à l'équipe de démarches simplifiees"
return redirect_to instructeur_procedure_path(procedure)
end
end
def procedure_id
params[:procedure_id]
end
def groupe_instructeurs
current_instructeur
.groupe_instructeurs
.where(procedure_id: procedure_id)
end
def procedure
current_instructeur
.procedures
.find(procedure_id)
end
end
end