demarches-normaliennes/app/helpers/commentaire_helper.rb
2018-10-26 10:10:20 +00:00

31 lines
898 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_is_from_me(commentaire, connected_user)
"from-me"
end
end
def commentaire_answer_action(commentaire, connected_user)
if commentaire_is_from_me(commentaire, 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 == Date.current.year)
template = is_current_year ? :message_date : :message_date_with_year
I18n.l(commentaire.created_at, format: template)
end
private
def commentaire_is_from_me(commentaire, connected_user)
commentaire.email == connected_user.email
end
end