Refine codes when postdate is nil.
This commit is contained in:
parent
fc14bb8105
commit
a9f96e0d22
|
@ -637,7 +637,7 @@ class AnnouncementsController < ApplicationController
|
||||||
anns = top_anns + rest_anns
|
anns = top_anns + rest_anns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
anns.each{|a| a["postdate"] = a["postdate"].in_time_zone(Time.zone.utc_offset / 3600).strftime('%Y-%m-%d %H:%M') rescue nil }
|
anns.each{|a| a["postdate"] = a["postdate"].in_time_zone(Time.zone.utc_offset / 3600).strftime('%Y-%m-%d %H:%M') if a["postdate"] }
|
||||||
anns
|
anns
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -814,7 +814,7 @@ class AnnouncementsController < ApplicationController
|
||||||
"title" => announcement.title,
|
"title" => announcement.title,
|
||||||
"subtitle_ann" => subtitle_ann,
|
"subtitle_ann" => subtitle_ann,
|
||||||
"update_user" => update_user,
|
"update_user" => update_user,
|
||||||
"updated_at" => (announcement.postdate.in_time_zone(Time.zone.utc_offset / 3600).strftime('%Y-%m-%d %H:%M') rescue ""),
|
"updated_at" => (announcement.postdate ? announcement.postdate.in_time_zone(Time.zone.utc_offset / 3600).strftime('%Y-%m-%d %H:%M') : ""),
|
||||||
"body" =>announcement.text,
|
"body" =>announcement.text,
|
||||||
"image" => announcement.image.url,
|
"image" => announcement.image.url,
|
||||||
"img_src" => img_src,
|
"img_src" => img_src,
|
||||||
|
@ -878,7 +878,7 @@ class AnnouncementsController < ApplicationController
|
||||||
|
|
||||||
OrbitHelper.render_meta_tags([{"property" => "og:title", "content" => announcement["title_translations"][locale]},{"property" => "og:site_name", "content" => Site.first.title},{"property" => "og:url", "content" => request.original_url.split("?").first},{"property" => "og:description", "content" => meta_desc},{"property" => "og:image", "content" => announcement["image"]["original"]},{"property" => "og:type", "content" => "Article"}])
|
OrbitHelper.render_meta_tags([{"property" => "og:title", "content" => announcement["title_translations"][locale]},{"property" => "og:site_name", "content" => Site.first.title},{"property" => "og:url", "content" => request.original_url.split("?").first},{"property" => "og:description", "content" => meta_desc},{"property" => "og:image", "content" => announcement["image"]["original"]},{"property" => "og:type", "content" => "Article"}])
|
||||||
|
|
||||||
datetime = DateTime.parse(announcement["postdate"])
|
datetime = announcement["postdate"] ? DateTime.parse(announcement["postdate"]) : nil
|
||||||
|
|
||||||
bulletin_carousel_images = Array(announcement["bulletin_carousel_images"])
|
bulletin_carousel_images = Array(announcement["bulletin_carousel_images"])
|
||||||
resume_btn_title = (I18n.locale.to_s =="zh_tw") ? "繼續播放" : "resume"
|
resume_btn_title = (I18n.locale.to_s =="zh_tw") ? "繼續播放" : "resume"
|
||||||
|
|
|
@ -146,6 +146,7 @@ module AnnouncementsHelper
|
||||||
end
|
end
|
||||||
flag = title.include?(keywords.to_s)
|
flag = title.include?(keywords.to_s)
|
||||||
end
|
end
|
||||||
|
if anns.postdate
|
||||||
if sflag && !eflag
|
if sflag && !eflag
|
||||||
flag = flag && (anns.postdate<=etime)
|
flag = flag && (anns.postdate<=etime)
|
||||||
elsif !sflag && eflag
|
elsif !sflag && eflag
|
||||||
|
@ -153,6 +154,7 @@ module AnnouncementsHelper
|
||||||
elsif !sflag && !eflag
|
elsif !sflag && !eflag
|
||||||
flag = flag && (anns.postdate>=stime) && (anns.postdate<=etime)
|
flag = flag && (anns.postdate>=stime) && (anns.postdate<=etime)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
flag
|
flag
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue