Download dossiers button exports all dossiers except draft

This commit is contained in:
Mathieu Magnin 2017-03-29 14:09:50 +02:00 committed by gregoirenovel
parent c17ebba916
commit b18c09e9fd
5 changed files with 58 additions and 34 deletions

View file

@ -201,6 +201,8 @@ class Dossier < ActiveRecord::Base
scope :archived, -> { where(archived: true) }
scope :downloadable, -> { all_state }
def cerfa_available?
procedure.cerfa_flag? && cerfa.size != 0
end
@ -261,21 +263,21 @@ class Dossier < ActiveRecord::Base
return headers
end
def self.export_full_generation(dossiers, format)
if dossiers && !dossiers.empty?
data = []
def self.export_full_generation(dossiers)
data = []
headers = []
if dossiers && dossiers.any?
headers = dossiers.first.export_headers
dossiers.each do |dossier|
data << dossier.convert_specific_array_values_to_string(dossier.data_with_champs)
end
if ["csv"].include?(format)
return SpreadsheetArchitect.to_csv(data: data, headers: headers)
elsif ["xlsx"].include?(format)
return SpreadsheetArchitect.to_xlsx(data: data, headers: headers)
elsif ["ods"].include?(format)
return SpreadsheetArchitect.to_ods(data: data, headers: headers)
end
end
return {
data: data,
headers: headers
}
end
def followers_gestionnaires_emails