demarches-normaliennes/app/serializers/dossier_table_export_serializer.rb
gregoirenovel d0a59058e8 Remove the mandataire_social guess
Rationale:
- is true for only 0.06% of Dossiers
- is not displayed anymore anyways
- will be a rare case for now
  * FC adoption is not insane
  * FC used more for personal than professional
    matters
  * not always the mandataires sociaux that fill
    dossiers for their companies, so not that
    relevant
- we can add it back later
2018-03-20 16:09:00 +01:00

68 lines
1.1 KiB
Ruby

class DossierTableExportSerializer < ActiveModel::Serializer
attributes :id,
:created_at,
:updated_at,
:archived,
:email,
:state,
:initiated_at,
:received_at,
:processed_at,
:motivation
attribute :emails_accompagnateurs
attributes :individual_gender,
:individual_prenom,
:individual_nom,
:individual_birthdate
def email
object.user.try(:email)
end
def state
case object.state
when 'en_construction'
'initiated'
when 'en_instruction'
'received'
when 'accepte'
'closed'
when 'refuse'
'refused'
when 'sans_suite'
'without_continuation'
else
object.state
end
end
def initiated_at
object.en_construction_at
end
def received_at
object.en_instruction_at
end
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
def emails_accompagnateurs
object.followers_gestionnaires.pluck(:email).join(' ')
end
end