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:
@@ -44,7 +44,11 @@ class NotificationsController < ApplicationController
|
|||||||
when "Topic"
|
when "Topic"
|
||||||
community_topic_path @notification.linkable_resource.community, @notification.linkable_resource
|
community_topic_path @notification.linkable_resource.community, @notification.linkable_resource
|
||||||
else
|
else
|
||||||
url_for @notification.linkable_resource
|
if @notification.linkable_resource.is_a?(AdminNotification)
|
||||||
|
@notification.linkable_resource.link || notifications_path
|
||||||
|
else
|
||||||
|
url_for @notification.linkable_resource
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -53,9 +53,19 @@ class Notification < ActiveRecord::Base
|
|||||||
"proposal_notification"
|
"proposal_notification"
|
||||||
when "Comment"
|
when "Comment"
|
||||||
"replies_to"
|
"replies_to"
|
||||||
|
when "AdminNotification"
|
||||||
|
nil
|
||||||
else
|
else
|
||||||
"comments_on"
|
"comments_on"
|
||||||
end
|
end
|
||||||
end
|
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