2014-12-16 11:40:15 +00:00
|
|
|
Rails.application.routes.draw do
|
|
|
|
|
|
|
|
locales = Site.first.in_use_locales rescue I18n.available_locales
|
2022-06-26 11:21:51 +00:00
|
|
|
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
|
|
|
|
Thread.new do
|
|
|
|
s = Site.first
|
|
|
|
update_flag = s.respond_to?(:tmp_flags)
|
2022-07-25 14:37:02 +00:00
|
|
|
need_update = !update_flag || !(s.tmp_flags.include?('cf2'))
|
2022-08-02 13:48:08 +00:00
|
|
|
need_update2 = !update_flag || !(s.tmp_flags.include?('cf3'))
|
2022-07-13 04:05:33 +00:00
|
|
|
calendar_setting = CalendarSetting.first
|
|
|
|
calendar_setting = CalendarSetting.create if calendar_setting.nil?
|
2022-06-26 11:21:51 +00:00
|
|
|
if need_update
|
|
|
|
Event.where(:title_translations.in=>[nil,{}]).each do |e|
|
|
|
|
e.title_translations = locales.map{|l| [l.to_s, e[:title]]}.to_h
|
|
|
|
e.save
|
|
|
|
end
|
|
|
|
Event.where(:note_translations.in=>[nil,{}]).each do |e|
|
|
|
|
e.note_translations = locales.map{|l| [l.to_s, e[:note]]}.to_h
|
|
|
|
e.save
|
|
|
|
end
|
|
|
|
Event.where(:url_translations=>nil).each do |e|
|
|
|
|
e.url_translations = locales.map{|l| [l.to_s, e[:url].to_s]}.to_h
|
|
|
|
e.save
|
|
|
|
end
|
2022-07-25 14:37:02 +00:00
|
|
|
Event.where(:period=>'Weekly',:weekdays=>nil).each do |e|
|
|
|
|
wday = e.start.wday rescue nil
|
|
|
|
e.weekdays = [wday]
|
|
|
|
e.save
|
|
|
|
end
|
2022-06-26 11:21:51 +00:00
|
|
|
if update_flag
|
|
|
|
s = Site.first
|
2022-07-25 14:37:02 +00:00
|
|
|
s.tmp_flags << 'cf2'
|
2022-06-26 11:21:51 +00:00
|
|
|
s.save
|
|
|
|
end
|
|
|
|
puts "Calendar fix!"
|
|
|
|
end
|
2022-08-02 13:48:08 +00:00
|
|
|
if need_update2
|
2022-08-02 14:17:35 +00:00
|
|
|
Event.where(:all_day=>true).each do |e|
|
2022-08-02 13:48:08 +00:00
|
|
|
if e.end == e.start + 1.day
|
|
|
|
e.end = e.start
|
|
|
|
e.save
|
|
|
|
end
|
|
|
|
end
|
2022-08-02 14:13:33 +00:00
|
|
|
if update_flag
|
|
|
|
s = Site.first
|
|
|
|
s.tmp_flags << 'cf3'
|
|
|
|
s.save
|
|
|
|
end
|
|
|
|
puts "Calendar fix!"
|
2022-08-02 13:48:08 +00:00
|
|
|
end
|
2022-06-26 11:21:51 +00:00
|
|
|
end
|
|
|
|
end
|
2014-12-16 11:40:15 +00:00
|
|
|
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
|
|
|
namespace :admin do
|
|
|
|
get "/calendars/agenda" => "calendars#agenda"
|
2022-07-13 04:05:33 +00:00
|
|
|
resources :calendars do
|
|
|
|
collection do
|
|
|
|
get 'calendar_setting'
|
|
|
|
post 'update_calendar_setting'
|
|
|
|
patch 'update_calendar_setting'
|
|
|
|
end
|
|
|
|
end
|
2014-12-16 11:40:15 +00:00
|
|
|
resources :calendar_types
|
|
|
|
end
|
|
|
|
|
|
|
|
get "/xhr/calendars/events" => "calendars#events"
|
|
|
|
get "/xhr/calendars/agenda" => "calendars#agenda"
|
2020-08-15 13:42:57 +00:00
|
|
|
get "/xhr/calendars/index_agenda" => "calendars#index_agenda"
|
|
|
|
|
2014-12-16 11:40:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|