This commit is contained in:
BoHung Chiu 2022-04-19 17:46:07 +08:00
parent 6123ed43bd
commit 218dd21255
2 changed files with 16 additions and 2 deletions

View File

@ -219,6 +219,11 @@ class AnnouncementsController < ApplicationController
get_tabs_option get_tabs_option
anns = [] anns = []
use_tag = false use_tag = false
@annc_depts = []
@tmp_enable_annc_dept = (enable_annc_dept rescue false)
if @tmp_enable_annc_dept
@annc_depts = annc_depts_translations[locale] rescue []
end
if @tab_option == 0 if @tab_option == 0
anns = get_anncs_for_pack_data(cats,tags,nil,is_random) anns = get_anncs_for_pack_data(cats,tags,nil,is_random)
else else
@ -537,6 +542,13 @@ class AnnouncementsController < ApplicationController
end end
end end
def get_anncs_for_pack_data(cats,tags,set_tags=nil,is_random = false) def get_anncs_for_pack_data(cats,tags,set_tags=nil,is_random = false)
if @annc_depts.nil?
@annc_depts = []
@tmp_enable_annc_dept = (enable_annc_dept rescue false)
if @tmp_enable_annc_dept
@annc_depts = annc_depts_translations[locale] rescue []
end
end
if tags.blank? if tags.blank?
tags = ["all"] tags = ["all"]
end end

View File

@ -20,7 +20,9 @@ module AnnouncementsHelper
end end
'#'+comp.join '#'+comp.join
end end
def data_to_human_type(a,set_tag_ids=nil) def data_to_human_type(a,set_tag_ids=nil,tmp_enable_annc_dept=false,annc_depts=[])
tmp_enable_annc_dept = @tmp_enable_annc_dept if @tmp_enable_annc_dept
annc_depts = @annc_depts if @annc_depts
statuses = a.statuses_with_classname.collect do |status| statuses = a.statuses_with_classname.collect do |status|
{ {
"status" => status["name"], "status" => status["name"],
@ -30,7 +32,7 @@ module AnnouncementsHelper
files = a.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } if file.enabled_for?(locale) } rescue [] files = a.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } if file.enabled_for?(locale) } rescue []
files.delete(nil) files.delete(nil)
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
author = User.find(a.create_user_id).member_profile.name rescue "" author = tmp_enable_annc_dept ? annc_depts[a.annc_dept] : User.find(a.create_user_id).member_profile.name rescue ""
desc = a.image_description desc = a.image_description
desc = (desc.nil? || desc == "" ? "announcement image" : desc) desc = (desc.nil? || desc == "" ? "announcement image" : desc)
link_to_show = (a.is_external_link? ? a.external_link : OrbitHelper.widget_item_url(a.to_param)) rescue "" link_to_show = (a.is_external_link? ? a.external_link : OrbitHelper.widget_item_url(a.to_param)) rescue ""