Allow notifications with explicit/unexistent links
Notifications usually link to the associated notifiable, but the new AdminNotifications have a link attribute that may be empty or contain an external or internal url.
This commit is contained in:
@@ -43,9 +43,13 @@ class NotificationsController < ApplicationController
|
||||
budget_investment_path @notification.linkable_resource.budget, @notification.linkable_resource
|
||||
when "Topic"
|
||||
community_topic_path @notification.linkable_resource.community, @notification.linkable_resource
|
||||
else
|
||||
if @notification.linkable_resource.is_a?(AdminNotification)
|
||||
@notification.linkable_resource.link || notifications_path
|
||||
else
|
||||
url_for @notification.linkable_resource
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -53,9 +53,19 @@ class Notification < ActiveRecord::Base
|
||||
"proposal_notification"
|
||||
when "Comment"
|
||||
"replies_to"
|
||||
when "AdminNotification"
|
||||
nil
|
||||
else
|
||||
"comments_on"
|
||||
end
|
||||
end
|
||||
|
||||
def link
|
||||
if notifiable.is_a?(AdminNotification) && notifiable.link.blank?
|
||||
nil
|
||||
else
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user