seminar2/app/helpers/admin/seminars_helper.rb

33 lines
950 B
Ruby
Raw Normal View History

2016-06-29 06:57:45 +00:00
module Admin::SeminarsHelper
def page_for_seminar(seminar)
ann_page = nil
pages = Page.where(:module=>'seminar')
pages.each do |page|
if page.categories.count ==1
if page.categories.include?(seminar.category.id.to_s)
ann_page = page
end
end
break if !ann_page.nil?
end
if ann_page.nil?
pages.each do |page|
if page.categories.include?(seminar.category.id.to_s)
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+'/'+seminar.to_param).gsub('//','/') rescue "/"
end
def page_for_seminar_url
page = Page.where(:module => 'seminar').first
return request.protocol+(request.host_with_port+"/#{I18n.locale}#{page.url}").gsub('//','/') rescue "/"
# return "/#{I18n.locale}#{page.url}/#{seminar.to_param}"
end
end