2016-03-14 10:34:46 +01:00
|
|
|
class CommentaireSerializer < ActiveModel::Serializer
|
|
|
|
attributes :email,
|
2017-06-12 13:49:51 +02:00
|
|
|
:body,
|
2018-10-24 15:17:41 +02:00
|
|
|
:created_at,
|
2024-06-10 13:06:31 +02:00
|
|
|
:piece_jointe_attachments,
|
|
|
|
:attachment
|
2018-10-24 15:17:41 +02:00
|
|
|
|
2018-10-31 10:29:03 +01:00
|
|
|
def created_at
|
|
|
|
object.created_at&.in_time_zone('UTC')
|
|
|
|
end
|
2024-06-10 13:06:31 +02:00
|
|
|
|
|
|
|
def attachment
|
|
|
|
piece_jointe = object.piece_jointe_attachments.first
|
|
|
|
|
|
|
|
if piece_jointe&.virus_scanner&.safe?
|
|
|
|
Rails.application.routes.url_helpers.url_for(piece_jointe)
|
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|