2016-01-20 15:48:46 +01:00
|
|
|
class DossierSerializer < ActiveModel::Serializer
|
|
|
|
attributes :id,
|
2017-06-12 13:49:51 +02:00
|
|
|
:created_at,
|
|
|
|
:updated_at,
|
|
|
|
:archived,
|
2017-08-01 14:19:58 +02:00
|
|
|
:email,
|
2017-06-12 13:49:51 +02:00
|
|
|
:state,
|
|
|
|
:simplified_state,
|
|
|
|
:initiated_at,
|
|
|
|
:received_at,
|
|
|
|
:processed_at,
|
2017-06-15 17:36:30 +02:00
|
|
|
:motivation,
|
2018-10-10 09:06:32 +02:00
|
|
|
:instructeurs
|
2016-01-25 16:08:10 +01:00
|
|
|
|
2017-12-11 15:15:03 +01:00
|
|
|
has_one :individual
|
2016-01-25 16:08:10 +01:00
|
|
|
has_one :entreprise
|
|
|
|
has_one :etablissement
|
2016-03-16 15:34:35 +01:00
|
|
|
has_many :cerfa
|
2016-03-14 10:34:46 +01:00
|
|
|
has_many :commentaires
|
2016-08-08 12:52:30 +02:00
|
|
|
has_many :champs_private
|
2016-03-17 17:33:38 +01:00
|
|
|
has_many :pieces_justificatives
|
2016-03-17 14:50:10 +01:00
|
|
|
has_many :types_de_piece_justificative
|
2017-04-14 17:38:08 +02:00
|
|
|
|
2017-10-27 15:36:07 +02:00
|
|
|
has_many :champs do
|
2017-10-30 16:54:33 +01:00
|
|
|
champs = object.champs + object.quartier_prioritaires + object.cadastres
|
|
|
|
if object.user_geometry.present?
|
|
|
|
champs << object.user_geometry
|
|
|
|
end
|
|
|
|
champs
|
2017-10-27 15:36:07 +02:00
|
|
|
end
|
|
|
|
|
2018-04-24 16:02:36 +02:00
|
|
|
def cerfa
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
2017-08-01 14:19:58 +02:00
|
|
|
def email
|
2018-05-30 18:45:46 +02:00
|
|
|
object.user&.email
|
2017-08-01 14:19:58 +02:00
|
|
|
end
|
|
|
|
|
2018-04-23 11:57:38 +02:00
|
|
|
def entreprise
|
|
|
|
object.etablissement&.entreprise
|
|
|
|
end
|
|
|
|
|
2017-12-14 15:51:45 +01:00
|
|
|
def state
|
2018-10-08 17:55:20 +02:00
|
|
|
object.old_state_value
|
2017-12-14 15:51:45 +01:00
|
|
|
end
|
|
|
|
|
2017-04-14 17:38:08 +02:00
|
|
|
def simplified_state
|
|
|
|
object.decorate.display_state
|
|
|
|
end
|
2017-04-14 18:10:39 +02:00
|
|
|
|
2017-12-14 15:51:45 +01:00
|
|
|
def initiated_at
|
2018-10-31 10:29:03 +01:00
|
|
|
object.en_construction_at&.in_time_zone('UTC')
|
2017-12-14 15:51:45 +01:00
|
|
|
end
|
|
|
|
|
2017-12-14 15:53:02 +01:00
|
|
|
def received_at
|
2018-10-31 10:29:03 +01:00
|
|
|
object.en_instruction_at&.in_time_zone('UTC')
|
2017-12-14 15:53:02 +01:00
|
|
|
end
|
|
|
|
|
2018-08-29 22:11:38 +02:00
|
|
|
def instructeurs
|
2017-04-14 18:10:39 +02:00
|
|
|
object.followers_gestionnaires.pluck(:email)
|
|
|
|
end
|
2017-04-14 18:20:14 +02:00
|
|
|
|
2018-10-31 10:29:03 +01:00
|
|
|
def created_at
|
|
|
|
object.created_at&.in_time_zone('UTC')
|
|
|
|
end
|
|
|
|
|
|
|
|
def updated_at
|
|
|
|
object.updated_at&.in_time_zone('UTC')
|
|
|
|
end
|
|
|
|
|
|
|
|
def processed_at
|
|
|
|
object.processed_at&.in_time_zone('UTC')
|
|
|
|
end
|
|
|
|
|
2017-10-30 16:54:33 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
def user_geometry(dossier)
|
|
|
|
{
|
|
|
|
value: dossier.geometry,
|
|
|
|
type_de_champ: {
|
|
|
|
id: -1,
|
|
|
|
libelle: 'user_geometry',
|
|
|
|
type_champ: 'user_geometry',
|
|
|
|
order_place: -1,
|
|
|
|
descripton: ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2016-11-09 15:36:18 +01:00
|
|
|
end
|