This commit is contained in:
邱博亞 2024-04-18 21:06:15 +08:00
parent e9f409a0f9
commit 40e0029fee
1 changed files with 13 additions and 13 deletions

View File

@ -132,24 +132,24 @@ class Act
statuses statuses
end 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? def is_external_link?
self.is_external_link && !self.external_link.blank? self.is_external_link && !self.external_link.blank?
end end
def signup_show def signup_show
@time_now ||= Time.now time_now = Time.now
if self.can_sign_up? if self.sign_up
sign_up = ('<a href="'+ (self.is_external_link? ? self.external_link : OrbitHelper.url_to_show(self.to_param)) + '" target="_blank">' + I18n.t('act.sign_up') + '</a>').html_safe sign_start_date_checked = (self.sign_start_date.nil? || self.sign_start_date <= time_now)
elsif self.sign_up sign_end_date_checked = (self.sign_end_date.nil? || self.sign_end_date >= time_now)
sign_up = I18n.t('act.sign_up_not_open') if sign_start_date_checked && sign_end_date_checked
elsif (self.sign_start_date > @time_now rescue false) sign_up_text = ('<a href="'+ (self.is_external_link? ? self.external_link : OrbitHelper.url_to_show(self.to_param)) + '" target="_blank">' + I18n.t('act.sign_up') + '</a>').html_safe
sign_up = I18n.t('act.sign_up_not_yet') elsif !sign_start_date_checked
sign_up_text = I18n.t('act.sign_up_not_yet')
else else
sign_up = I18n.t('act.sign_up_overdue') sign_up_text = I18n.t('act.sign_up_overdue')
end
else
sign_up_text = I18n.t('act.sign_up_not_open')
end end
end end