demarches-normaliennes/app/helpers/commentaire_helper.rb

32 lines
898 B
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_is_from_me(commentaire, connected_user)
2017-12-14 17:10:13 +01:00
"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
2017-12-14 17:10:13 +01:00
end