0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00

Only check if time is valid if time has changed

Dieser Commit ist enthalten in:
Angus McLeod 2018-06-06 23:49:28 +10:00
Ursprung e8a28ad22d
Commit 6fab152930

Datei anzeigen

@ -17,6 +17,8 @@ class CustomWizard::AdminController < ::ApplicationController
existing = PluginStore.get('custom_wizard', wizard['id']) || {} existing = PluginStore.get('custom_wizard', wizard['id']) || {}
new_time = false
error = nil error = nil
if wizard["id"].blank? if wizard["id"].blank?
@ -30,8 +32,13 @@ class CustomWizard::AdminController < ::ApplicationController
error = 'after_time_need_time' error = 'after_time_need_time'
else else
after_time_scheduled = Time.parse(wizard["after_time_scheduled"]).utc after_time_scheduled = Time.parse(wizard["after_time_scheduled"]).utc
new_time = existing['after_time_scheduled'] ?
after_time_scheduled != Time.parse(existing['after_time_scheduled']).utc :
true
begin begin
if after_time_scheduled < Time.now.utc if new_time && after_time_scheduled < Time.now.utc
error = 'after_time_invalid' error = 'after_time_invalid'
end end
rescue ArgumentError rescue ArgumentError
@ -88,10 +95,6 @@ class CustomWizard::AdminController < ::ApplicationController
s['description'] = PrettyText.cook(s['raw_description']) if s['raw_description'] s['description'] = PrettyText.cook(s['raw_description']) if s['raw_description']
end end
new_time = existing['after_time_scheduled'] ?
after_time_scheduled != Time.parse(existing['after_time_scheduled']).utc :
true
if wizard['after_time'] && new_time if wizard['after_time'] && new_time
Jobs.cancel_scheduled_job(:set_after_time_wizard, wizard_id: wizard['id']) Jobs.cancel_scheduled_job(:set_after_time_wizard, wizard_id: wizard['id'])
Jobs.enqueue_at(after_time_scheduled, :set_after_time_wizard, wizard_id: wizard['id']) Jobs.enqueue_at(after_time_scheduled, :set_after_time_wizard, wizard_id: wizard['id'])