Fix: 新規登録可能時間帯を空欄にすると、画面が表示できなくなる問題 (#603)
* Fix: 新規登録可能時間帯を空欄にすると、画面が表示できなくなる問題 * リファクタリング * Fix test
This commit is contained in:
parent
ad723b0cbd
commit
8a9a29cba1
1 changed files with 11 additions and 9 deletions
|
@ -32,20 +32,22 @@ module RegistrationLimitationHelper
|
|||
end
|
||||
|
||||
def registrations_in_time?
|
||||
start_hour = Setting.registrations_start_hour || 0
|
||||
end_hour = Setting.registrations_end_hour || 24
|
||||
secondary_start_hour = Setting.registrations_secondary_start_hour || 0
|
||||
secondary_end_hour = Setting.registrations_secondary_end_hour || 0
|
||||
start_hour = Setting.registrations_start_hour
|
||||
end_hour = Setting.registrations_end_hour
|
||||
secondary_start_hour = Setting.registrations_secondary_start_hour
|
||||
secondary_end_hour = Setting.registrations_secondary_end_hour
|
||||
|
||||
start_hour = 0 unless start_hour.is_a?(Integer)
|
||||
end_hour = 0 unless end_hour.is_a?(Integer)
|
||||
secondary_start_hour = 0 unless secondary_start_hour.is_a?(Integer)
|
||||
secondary_end_hour = 0 unless secondary_end_hour.is_a?(Integer)
|
||||
|
||||
return true if start_hour >= end_hour && secondary_start_hour >= secondary_end_hour
|
||||
|
||||
current_hour = Time.now.utc.hour
|
||||
primary_permitted = false
|
||||
primary_permitted = start_hour <= current_hour && current_hour < end_hour if start_hour < end_hour && end_hour.positive?
|
||||
secondary_permitted = false
|
||||
secondary_permitted = secondary_start_hour <= current_hour && current_hour < secondary_end_hour if secondary_start_hour < secondary_end_hour && secondary_end_hour.positive?
|
||||
|
||||
primary_permitted || secondary_permitted
|
||||
(start_hour < end_hour && end_hour.positive? && current_hour.between?(start_hour, end_hour - 1)) ||
|
||||
(secondary_start_hour < secondary_end_hour && secondary_end_hour.positive? && current_hour.between?(secondary_start_hour, secondary_end_hour - 1))
|
||||
end
|
||||
|
||||
def reset_registration_limit_caches!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue