diff --git a/app/helpers/admin/announcements_helper.rb b/app/helpers/admin/announcements_helper.rb index e7106b2..c280c64 100644 --- a/app/helpers/admin/announcements_helper.rb +++ b/app/helpers/admin/announcements_helper.rb @@ -4,29 +4,33 @@ require 'json' module Admin::AnnouncementsHelper def page_for_bulletin(bulletin) - ann_page = nil - pages = Page.where(:module=>'announcement').select{|page| page.enabled_for.include?(I18n.locale.to_s)} + if !bulletin.is_external_link || bulletin.external_link.blank? + ann_page = nil + pages = Page.where(:module=>'announcement').select{|page| page.enabled_for.include?(I18n.locale.to_s)} - pages.each do |page| - if page.categories.count ==1 - if (page.categories.include?(bulletin.category.id.to_s) rescue false) - ann_page = page - end - end - break if !ann_page.nil? - end - - if ann_page.nil? - pages.each do |page| - if (page.categories.include?(bulletin.category.id.to_s) rescue false) - ann_page = page + pages.each do |page| + if page.categories.count ==1 + if (page.categories.include?(bulletin.category.id.to_s) rescue false) + ann_page = page + end end break if !ann_page.nil? end - end - ann_page = pages.first if ann_page.nil? - request.protocol+(request.host_with_port+ann_page.url+'/'+bulletin.to_param).gsub('//','/') rescue "#" + if ann_page.nil? + pages.each do |page| + if (page.categories.include?(bulletin.category.id.to_s) rescue false) + ann_page = page + end + break if !ann_page.nil? + end + end + + ann_page = pages.first if ann_page.nil? + request.protocol+(request.host_with_port+ann_page.url+'/'+bulletin.to_param).gsub('//','/') rescue "#" + else + bulletin.external_link + end end def import_this_announcement(row,categories,tags)