[#2180] Expose migrated PJs as legacy PJs in dossier API
This commit is contained in:
parent
5f74ae1545
commit
bf23abdfe3
3 changed files with 58 additions and 0 deletions
|
@ -47,6 +47,11 @@ class DossierSerializer < ActiveModel::Serializer
|
|||
[]
|
||||
end
|
||||
|
||||
def pieces_justificatives
|
||||
ActiveModelSerializers::SerializableResource.new(object.pieces_justificatives).serializable_hash +
|
||||
PiecesJustificativesService.serialize_champs_as_pjs(object)
|
||||
end
|
||||
|
||||
def email
|
||||
object.user&.email
|
||||
end
|
||||
|
|
|
@ -84,4 +84,15 @@ class PiecesJustificativesService
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
def self.serialize_champs_as_pjs(dossier)
|
||||
dossier.champs.select { |champ| champ.type_de_champ.old_pj }.map do |champ|
|
||||
{
|
||||
created_at: champ.created_at&.in_time_zone('UTC'),
|
||||
type_de_piece_justificative_id: champ.type_de_champ.old_pj[:stable_id],
|
||||
content_url: champ.for_api,
|
||||
user: champ.dossier.user
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue