module Manager class OutdatedProceduresController < Manager::ApplicationController def index @records_per_page = params[:records_per_page] || "10" resources = Procedure.all .where(procedure_expires_when_termine_enabled: false) .order(created_at: :asc) .page(params[:_page]) .per(@records_per_page) page = Administrate::Page::Collection.new(dashboard) render locals: { resources: resources, page: page, show_search_bar: false } end def bulk_update procedure_ids = params[:procedure][:ids].filter { |_id, selected| selected == "1" } .keys successes = procedure_ids.map do |id| procedure = Procedure.find(id) success = procedure.update(procedure_expires_when_termine_enabled: true) if success administration_emails = procedure.administrateurs.map(&:email) administration_emails.each do |email| AdministrateurMailer.notify_procedure_expires_when_termine_forced(email, procedure).deliver_later end end success end flash[:notice] = "L'archivage automatique a été activé sur les #{successes.size} procédure(s) choisies" redirect_to manager_outdated_procedures_path end end end