announcement-test/app/helpers/admin/announcements_helper.rb

50 lines
1.1 KiB
Ruby
Raw Normal View History

2014-04-03 03:18:02 +00:00
module Admin::AnnouncementsHelper
2014-05-02 10:21:51 +00:00
def page_for_bulletin(bulletin)
2014-05-28 07:37:56 +00:00
ann_page = nil
pages = Page.where(:module=>'announcement')
pages.each do |page|
if page.categories.count ==1
if page.categories.include?(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?(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+'/'+bulletin.to_param).gsub('//','/') rescue "/"
2014-05-02 10:21:51 +00:00
end
2014-09-22 08:32:30 +00:00
def load_access_level
2014-10-20 10:53:31 +00:00
if (current_user.is_admin? rescue false)
2014-09-22 08:32:30 +00:00
@access_level = "admin"
2014-10-20 10:53:31 +00:00
elsif (current_user.is_manager?(@module_app) rescue false)
2014-09-22 08:32:30 +00:00
@access_level = "manager"
2014-10-20 10:53:31 +00:00
else
@access_level = "users"
2014-09-22 08:32:30 +00:00
end
end
def user_can_approve?
case @access_level
when "admin"
return true
when "manager"
return true
else
return false
end
end
2014-04-03 03:18:02 +00:00
end