Dossier: workaround preview bug linked to champs with dossier.id == 0

This commit is contained in:
Simon Lehericey 2017-08-29 16:30:34 +02:00
parent 0118c43d95
commit 5737ebd090

View file

@ -121,11 +121,15 @@ class Dossier < ActiveRecord::Base
end end
def ordered_champs def ordered_champs
champs.includes(:type_de_champ).order('types_de_champ.order_place') # TODO: use the line below when the procedure preview does not leak champ with dossier_id == 0
# champs.joins(:type_de_champ).order('types_de_champ.order_place')
champs.joins(', types_de_champ').where("champs.type_de_champ_id = types_de_champ.id AND types_de_champ.procedure_id = #{procedure.id}").order('order_place')
end end
def ordered_champs_private def ordered_champs_private
champs_private.includes(:type_de_champ).order('types_de_champ.order_place') # TODO: use the line below when the procedure preview does not leak champ with dossier_id == 0
# champs_private.includes(:type_de_champ).order('types_de_champ.order_place')
champs_private.joins(', types_de_champ').where("champs.type_de_champ_id = types_de_champ.id AND types_de_champ.procedure_id = #{procedure.id}").order('order_place')
end end
def ordered_pieces_justificatives def ordered_pieces_justificatives