This commit is contained in:
BoHung Chiu 2021-11-03 10:44:57 +08:00
parent 8766770119
commit 9f3a4fb528
1 changed files with 4 additions and 2 deletions

View File

@ -133,18 +133,20 @@ class Act
end
def can_sign_up?
(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
@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 = ('<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
elsif self.sign_up
sign_up = I18n.t('act.sign_up_not_open')
elsif (self.sign_start_date > time_now rescue false)
elsif (self.sign_start_date > @time_now rescue false)
sign_up = I18n.t('act.sign_up_not_yet')
else
sign_up = I18n.t('act.sign_up_overdue')