fix external link bug

This commit is contained in:
chiu 2021-09-16 00:12:26 +08:00
parent de2eb5f0af
commit 51028d1372
1 changed files with 22 additions and 18 deletions

View File

@ -4,29 +4,33 @@ require 'json'
module Admin::AnnouncementsHelper module Admin::AnnouncementsHelper
def page_for_bulletin(bulletin) def page_for_bulletin(bulletin)
ann_page = nil if !bulletin.is_external_link || bulletin.external_link.blank?
pages = Page.where(:module=>'announcement').select{|page| page.enabled_for.include?(I18n.locale.to_s)} ann_page = nil
pages = Page.where(:module=>'announcement').select{|page| page.enabled_for.include?(I18n.locale.to_s)}
pages.each do |page| pages.each do |page|
if page.categories.count ==1 if page.categories.count ==1
if (page.categories.include?(bulletin.category.id.to_s) rescue false) if (page.categories.include?(bulletin.category.id.to_s) rescue false)
ann_page = page ann_page = page
end 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
end end
break if !ann_page.nil? break if !ann_page.nil?
end end
end
ann_page = pages.first if ann_page.nil? if ann_page.nil?
request.protocol+(request.host_with_port+ann_page.url+'/'+bulletin.to_param).gsub('//','/') rescue "#" 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 end
def import_this_announcement(row,categories,tags) def import_this_announcement(row,categories,tags)