demarches-normaliennes/app/helpers/commentaire_helper.rb
2020-08-10 17:36:23 +02:00

30 lines
925 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module CommentaireHelper
def commentaire_is_from_me_class(commentaire, connected_user)
if commentaire.sent_by?(connected_user)
"from-me"
end
end
def commentaire_answer_action(commentaire, connected_user)
if commentaire.sent_by?(connected_user)
"Envoyer un message à linstructeur"
else
"Répondre dans la messagerie"
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
def pretty_commentaire(commentaire)
body_formatted = commentaire.sent_by_system? ? commentaire.body : simple_format(commentaire.body)
sanitize(body_formatted)
end
end