Add translation key method, should be replaced with separate partials.
This commit is contained in:
parent
1c1fba63e7
commit
00cca370ad
6 changed files with 21 additions and 8 deletions
|
|
@ -1,33 +1,31 @@
|
|||
module NotificationsHelper
|
||||
def object_link(note)
|
||||
target_type = note.class
|
||||
case target_type
|
||||
when Notifications::Mentioned
|
||||
target_type = note.translation_key
|
||||
if note.instance_of?(Notifications::Mentioned)
|
||||
post = Mention.find(note.target_id).post
|
||||
if post
|
||||
"#{translation(target_type)} #{link_to t('notifications.post'), object_path(post)}".html_safe
|
||||
else
|
||||
"#{translation(target_type)} #{t('notifications.deleted')} #{t('notifications.post')}"
|
||||
end
|
||||
when Notifications::RequestAccepted
|
||||
elsif note.instance_of?(Notifications::RequestAccepted)
|
||||
translation(target_type)
|
||||
when Notifications::NewRequest
|
||||
elsif note.instance_of?(Notifications::NewRequest)
|
||||
translation(target_type)
|
||||
when Notifications::CommentOnPost
|
||||
elsif note.instance_of?(Notifications::CommentOnPost)
|
||||
post = Post.where(:id => note.target_id).first
|
||||
if post
|
||||
"#{translation(target_type)} #{link_to t('notifications.post'), object_path(post)}".html_safe
|
||||
else
|
||||
"#{translation(target_type)} #{t('notifications.deleted')} #{t('notifications.post')}"
|
||||
end
|
||||
when Notifications::AlsoCommented
|
||||
elsif note.instance_of?(Notifications::AlsoCommented)
|
||||
post = Post.where(:id => note.target_id).first
|
||||
if post
|
||||
"#{translation(target_type, post.person.name)} #{link_to t('notifications.post'), object_path(post)}".html_safe
|
||||
else
|
||||
t('notifications.also_commented_deleted')
|
||||
end
|
||||
else
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,4 +2,7 @@ class Notifications::AlsoCommented < Notification
|
|||
def mail_job
|
||||
Job::MailAlsoCommented
|
||||
end
|
||||
def translation_key
|
||||
'also_commented'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,4 +2,7 @@ class Notifications::CommentOnPost < Notification
|
|||
def mail_job
|
||||
Job::MailCommentOnPost
|
||||
end
|
||||
def translation_key
|
||||
'comment_on_post'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,4 +2,7 @@ class Notifications::Mentioned < Notification
|
|||
def mail_job
|
||||
Job::MailMentioned
|
||||
end
|
||||
def translation_key
|
||||
'mentioned'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,4 +2,7 @@ class Notifications::NewRequest < Notification
|
|||
def mail_job
|
||||
Job::MailRequestReceived
|
||||
end
|
||||
def translation_key
|
||||
'new_request'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,4 +2,7 @@ class Notifications::RequestAccepted < Notification
|
|||
def mail_job
|
||||
Job::MailRequestAcceptance
|
||||
end
|
||||
def translation_key
|
||||
'request_accepted'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue