From 40e0029fee0190d3a3de429b39c25b456b3e36a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Thu, 18 Apr 2024 21:06:15 +0800 Subject: [PATCH] Fix bug. --- app/models/act.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/models/act.rb b/app/models/act.rb index c6173d3..87dea98 100644 --- a/app/models/act.rb +++ b/app/models/act.rb @@ -131,25 +131,25 @@ class Act statuses << {"name" => hidden_text, "classname" => "hidden"} if is_hidden? statuses end - - def can_sign_up? - @time_now ||= Time.now - (self.sign_up && (self.sign_start_date.blank? || self.sign_start_date <= @time_now) && ( self.sign_end_date.blank? || self.sign_end_date >= @time_now )) rescue false - end def is_external_link? self.is_external_link && !self.external_link.blank? end + def signup_show - @time_now ||= Time.now - if self.can_sign_up? - sign_up = ('' + I18n.t('act.sign_up') + '').html_safe - elsif self.sign_up - sign_up = I18n.t('act.sign_up_not_open') - elsif (self.sign_start_date > @time_now rescue false) - sign_up = I18n.t('act.sign_up_not_yet') + time_now = Time.now + if self.sign_up + sign_start_date_checked = (self.sign_start_date.nil? || self.sign_start_date <= time_now) + sign_end_date_checked = (self.sign_end_date.nil? || self.sign_end_date >= time_now) + if sign_start_date_checked && sign_end_date_checked + sign_up_text = ('' + I18n.t('act.sign_up') + '').html_safe + elsif !sign_start_date_checked + sign_up_text = I18n.t('act.sign_up_not_yet') + else + sign_up_text = I18n.t('act.sign_up_overdue') + end else - sign_up = I18n.t('act.sign_up_overdue') + sign_up_text = I18n.t('act.sign_up_not_open') end end