demarches-normaliennes/app/helpers/commentaire_helper.rb

32 lines
1 KiB
Ruby
Raw Normal View History

2017-12-14 17:10:13 +01:00
module CommentaireHelper
def commentaire_is_from_me_class(commentaire, connected_user)
if commentaire.sent_by?(connected_user)
2017-12-14 17:10:13 +01:00
"from-me"
end
end
def commentaire_answer_action(commentaire, connected_user)
if commentaire.sent_by?(connected_user)
2021-04-17 18:49:00 +02:00
I18n.t('helpers.commentaire.send_message_to_instructeur')
else
2021-04-17 18:49:00 +02:00
I18n.t('helpers.commentaire.reply_in_mailbox')
end
end
def commentaire_is_from_guest(commentaire)
commentaire.dossier.invites.map(&:email).include?(commentaire.email)
end
def commentaire_date(commentaire)
is_current_year = (commentaire.created_at.year == Time.zone.today.year)
template = is_current_year ? :message_date : :message_date_with_year
I18n.l(commentaire.created_at, format: template)
end
2020-08-10 16:02:11 +02:00
def pretty_commentaire(commentaire)
return t('views.shared.commentaires.destroy.deleted_body') if commentaire.discarded?
2020-08-10 16:02:11 +02:00
body_formatted = commentaire.sent_by_system? ? commentaire.body : simple_format(commentaire.body)
sanitize(body_formatted)
end
2017-12-14 17:10:13 +01:00
end