nccu-news/app/helpers/admin/news_helper.rb

48 lines
1.0 KiB
Ruby
Raw Normal View History

2014-11-07 08:44:11 +00:00
module Admin::NewsHelper
def page_for_news_bulletin(news_bulletin)
ann_page = nil
pages = Page.where(:module=>'news')
pages.each do |page|
if page.categories.count ==1
if page.categories.include?(news_bulletin.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?(news_bulletin.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+'/'+news_bulletin.to_param).gsub('//','/') rescue "/"
end
def load_access_level
if current_user.is_admin?
@access_level = "admin"
elsif current_user.is_manager?(@module_app)
@access_level = "manager"
end
end
def user_can_approve?
case @access_level
when "admin"
return true
when "manager"
return true
else
return false
end
end
end