demarches-normaliennes/app/controllers/instructeurs/archives_controller.rb
Christophe Robillard 54d91335f2 remove the ability to download an 'everything' archive
there are sometimes an error that happen when building an everything
archive. The error explanation is not understood at the moment.
To deliver the archive feature quickly, we remove the 'everything' archive for
the moment
2021-07-05 11:05:07 +02:00

55 lines
1.8 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
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.feature_enabled?(:archive_zip_globale) || 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