Add event_end_date

This commit is contained in:
chiu 2026-06-05 07:37:08 +00:00
parent 68dcf25f25
commit 1025cb4438
1 changed files with 24 additions and 24 deletions

View File

@ -1,24 +1,24 @@
class EventNewsCustomTitle class EventNewsCustomTitle
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
field :key field :key
field :title, type: String, localize: true field :title, type: String, localize: true
KEYS = ['category', 'title','speaker','host','event_date','place','notes'] KEYS = ['category', 'title','speaker','host','event_date','event_end_date','place','notes']
def self.get_map def self.get_map
KEYS.map do |k| KEYS.map do |k|
s = self.where(key: k).first || self.create(key: k,title_translations: I18n.available_locales.map{|l| [l,I18n.with_locale(l){I18n.t("event_news.#{k}")}]}.to_h) s = self.where(key: k).first || self.create(key: k,title_translations: I18n.available_locales.map{|l| [l,I18n.with_locale(l){I18n.t("event_news.#{k}")}]}.to_h)
if s.title_translations.select{|k,v| v.include?("translation missing")}.length>0 if s.title_translations.select{|k,v| v.include?("translation missing")}.length>0
s.update_attributes(title_translations: I18n.available_locales.map{|l| [l,I18n.with_locale(l){I18n.t("event_news.#{k}")}]}.to_h) s.update_attributes(title_translations: I18n.available_locales.map{|l| [l,I18n.with_locale(l){I18n.t("event_news.#{k}")}]}.to_h)
end end
s s
end end
end end
def default_title def default_title
I18n.t("event_news.#{self.key}") I18n.t("event_news.#{self.key}")
end end
def self.get_trans(key) def self.get_trans(key)
tmp = TitleMap[key][I18n.locale] rescue I18n.t("event_news.#{key}") tmp = TitleMap[key][I18n.locale] rescue I18n.t("event_news.#{key}")
tmp.blank? ? I18n.t("event_news.#{key}") : tmp tmp.blank? ? I18n.t("event_news.#{key}") : tmp
end end
TitleMap = self.get_map.map{|v| [v.key,v.title_translations]}.to_h TitleMap = self.get_map.map{|v| [v.key,v.title_translations]}.to_h
end end