fix(sentry#6088812113): avoid crash when trying to export a repetition which is not in a dossier revision

This commit is contained in:
mfo 2024-11-26 11:05:15 +01:00
parent 266bba941a
commit a88325e224
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
3 changed files with 6 additions and 1 deletions

View file

@ -29,7 +29,7 @@ module ChampsValidateConcern
end end
def in_dossier_revision? def in_dossier_revision?
dossier.revision.types_de_champ.any? { _1.stable_id == stable_id } && is_type?(type_de_champ.type_champ) dossier.revision.in_revision?(stable_id) && is_type?(type_de_champ.type_champ)
end end
end end
end end

View file

@ -109,6 +109,7 @@ module DossierChampsConcern
def repetition_row_ids(type_de_champ) def repetition_row_ids(type_de_champ)
return [] if !type_de_champ.repetition? return [] if !type_de_champ.repetition?
return [] if !revision.in_revision?(type_de_champ.stable_id)
stable_ids = revision.children_of(type_de_champ).map(&:stable_id) stable_ids = revision.children_of(type_de_champ).map(&:stable_id)
champs.filter { _1.stable_id.in?(stable_ids) && _1.row_id.present? } champs.filter { _1.stable_id.in?(stable_ids) && _1.row_id.present? }

View file

@ -203,6 +203,10 @@ class ProcedureRevision < ApplicationRecord
coordinate_for(tdc).parent_type_de_champ coordinate_for(tdc).parent_type_de_champ
end end
def in_revision?(stable_id)
types_de_champ.any? { _1.stable_id == stable_id }
end
def dependent_conditions(tdc) def dependent_conditions(tdc)
stable_id = tdc.stable_id stable_id = tdc.stable_id