This repository has been archived on 2023-09-12. You can view files and clone it, but cannot push or open issues or pull requests.
2014-11-07 08:32:00 +00:00
|
|
|
module Admin::AnnouncementsHelper
|
|
|
|
def page_for_bulletin(bulletin)
|
|
|
|
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
|
|
|
|
|
2015-01-07 09:26:39 +00:00
|
|
|
|
|
|
|
if Page.where(:module=>'announcement',:url => "/announcement").count ==1
|
|
|
|
ann_page = '/announcement'
|
|
|
|
else
|
|
|
|
ann_page = pages.first.url if ann_page.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
request.protocol+(request.host_with_port+ann_page+'/'+bulletin.to_param).gsub('//','/') rescue "/"
|
2014-11-07 08:32:00 +00:00
|
|
|
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
|