Catching case for empty dossiers, cannot download them while locked on procedure, third fix making good condition about empty dossiers
This commit is contained in:
parent
2670a9db0e
commit
45042d0200
2 changed files with 14 additions and 12 deletions
|
@ -41,7 +41,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||||
def download_dossiers_tps
|
def download_dossiers_tps
|
||||||
if procedure = Procedure.find_by(id: params[:procedure_id])
|
if procedure = Procedure.find_by(id: params[:procedure_id])
|
||||||
dossiers = dossiers_list_facade(param_liste).dossiers_to_display
|
dossiers = dossiers_list_facade(param_liste).dossiers_to_display
|
||||||
respond_with Dossier.export_full_generation(dossiers, request.format) if dossiers.empty?
|
respond_with Dossier.export_full_generation(dossiers, request.format) unless dossiers.empty?
|
||||||
else
|
else
|
||||||
dossiers = dossiers_list_facade(param_liste).dossiers_to_display
|
dossiers = dossiers_list_facade(param_liste).dossiers_to_display
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
@ -293,6 +293,7 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.export_full_generation(dossiers, format)
|
def self.export_full_generation(dossiers, format)
|
||||||
|
if dossiers && !dossiers.empty?
|
||||||
data = []
|
data = []
|
||||||
headers = dossiers.first.export_headers
|
headers = dossiers.first.export_headers
|
||||||
dossiers.each do |dossier|
|
dossiers.each do |dossier|
|
||||||
|
@ -306,6 +307,7 @@ class Dossier < ActiveRecord::Base
|
||||||
return SpreadsheetArchitect.to_ods(data: data, headers: headers)
|
return SpreadsheetArchitect.to_ods(data: data, headers: headers)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def reset!
|
def reset!
|
||||||
etablissement.destroy
|
etablissement.destroy
|
||||||
|
|
Loading…
Reference in a new issue