fix error

This commit is contained in:
邱博亞 2022-04-26 11:35:11 +08:00
parent 920a8880ce
commit 78e69ceb50
3 changed files with 18 additions and 1 deletions

View File

@ -673,8 +673,9 @@ class AnnouncementsController < ApplicationController
else else
announcement = Bulletin.can_display_and_sorted.where(:uid => uid).first announcement = Bulletin.can_display_and_sorted.where(:uid => uid).first
end end
@bulletin = announcement
announcement = Bulletin.where(:uid => uid).first if announcement.nil? announcement = Bulletin.where(:uid => uid).first if announcement.nil?
@bulletin = announcement
url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/announcements/#{announcement.id.to_s}/edit" : "" url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/announcements/#{announcement.id.to_s}/edit" : ""
access_level = OrbitHelper.user_access_level? access_level = OrbitHelper.user_access_level?
@ -691,6 +692,18 @@ class AnnouncementsController < ApplicationController
return {} if (announcement.category.disable rescue false) return {} if (announcement.category.disable rescue false)
if !announcement.deadline.nil? && announcement.deadline < Time.now
return {
"tags" => [],
"bulletin_files" => [],
"bulletin_links" => [],
"data" => {
"title" => announcement.title,
"body" => "<b class='announcement_expired'>#{I18n.t('announcement.expired')}</b><br><a class='announcement_go_back_list' href='../' title='#{I18n.t('announcement.go_back')}'>#{I18n.t('announcement.go_back')}</a>".html_safe
}
}
end
tags = announcement.tags.map{|tag| { tags = announcement.tags.map{|tag| {
"tag" => tag.name , "tag" => tag.name ,
"url" => OrbitHelper.page_for_tag(tag) "url" => OrbitHelper.page_for_tag(tag)

View File

@ -3,6 +3,8 @@ en:
feed: Feed feed: Feed
import: Import import: Import
announcement: announcement:
expired: This announcement has been expired.
go_back: Go back to the list of announcements.
annc_dept: Department annc_dept: Department
manually_sort: Manually Sort manually_sort: Manually Sort
enable_manually_sort: Enable Manually Sort enable_manually_sort: Enable Manually Sort

View File

@ -4,6 +4,8 @@ zh_tw:
import: 匯入 import: 匯入
get_all_anncs_without_subannc: "選擇相關公告" get_all_anncs_without_subannc: "選擇相關公告"
announcement: announcement:
expired: 此則公告已過期
go_back: 回到公告列表
annc_dept: 公告單位 annc_dept: 公告單位
manually_sort: 手動排序 manually_sort: 手動排序
enable_manually_sort: 開啟手動排序 enable_manually_sort: 開啟手動排序