2017-04-13 15:05:55 +02:00
|
|
|
class DossierTableExportSerializer < ActiveModel::Serializer
|
|
|
|
attributes :id,
|
2017-06-12 13:49:51 +02:00
|
|
|
:created_at,
|
|
|
|
:updated_at,
|
|
|
|
:archived,
|
2017-08-01 14:18:20 +02:00
|
|
|
:email,
|
2017-06-12 13:49:51 +02:00
|
|
|
:state,
|
|
|
|
:initiated_at,
|
|
|
|
:received_at,
|
2017-06-19 10:20:46 +02:00
|
|
|
:processed_at,
|
|
|
|
:motivation
|
2017-04-13 15:05:55 +02:00
|
|
|
|
2017-04-14 18:10:39 +02:00
|
|
|
attribute :emails_accompagnateurs
|
2017-04-13 15:05:55 +02:00
|
|
|
|
|
|
|
attributes :individual_gender,
|
2017-06-12 13:49:51 +02:00
|
|
|
:individual_prenom,
|
|
|
|
:individual_nom,
|
|
|
|
:individual_birthdate
|
2017-04-13 15:05:55 +02:00
|
|
|
|
2017-08-01 14:18:20 +02:00
|
|
|
def email
|
|
|
|
object.user.try(:email)
|
|
|
|
end
|
|
|
|
|
2017-12-14 15:51:45 +01:00
|
|
|
def state
|
|
|
|
case object.state
|
|
|
|
when 'en_construction'
|
|
|
|
'initiated'
|
2017-12-14 15:53:02 +01:00
|
|
|
when 'en_instruction'
|
|
|
|
'received'
|
2017-12-04 18:00:12 +01:00
|
|
|
when 'accepte'
|
|
|
|
'closed'
|
2017-12-04 18:15:40 +01:00
|
|
|
when 'refuse'
|
|
|
|
'refused'
|
2017-12-04 20:23:57 +01:00
|
|
|
when 'sans_suite'
|
|
|
|
'without_continuation'
|
2017-12-14 15:51:45 +01:00
|
|
|
else
|
|
|
|
object.state
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def initiated_at
|
|
|
|
object.en_construction_at
|
|
|
|
end
|
|
|
|
|
2017-12-14 15:53:02 +01:00
|
|
|
def received_at
|
|
|
|
object.en_instruction_at
|
|
|
|
end
|
|
|
|
|
2017-04-13 15:05:55 +02:00
|
|
|
def individual_prenom
|
|
|
|
object.individual.try(:prenom)
|
|
|
|
end
|
|
|
|
|
|
|
|
def individual_nom
|
|
|
|
object.individual.try(:nom)
|
|
|
|
end
|
|
|
|
|
|
|
|
def individual_birthdate
|
|
|
|
object.individual.try(:birthdate)
|
|
|
|
end
|
|
|
|
|
|
|
|
def individual_gender
|
|
|
|
object.individual.try(:gender)
|
|
|
|
end
|
2017-04-14 18:10:39 +02:00
|
|
|
|
|
|
|
def emails_accompagnateurs
|
|
|
|
object.followers_gestionnaires.pluck(:email).join(' ')
|
|
|
|
end
|
2017-04-13 15:05:55 +02:00
|
|
|
end
|