diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-02-16 22:29:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 22:29:48 +0100 |
commit | ac99f586bb4138e083676579097d951434e90515 (patch) | |
tree | 2ab02a0a811e96052eb0fc41875f1e8d2709f035 /app/models | |
parent | aa86cf955755cd05ed9c274daebbec248c39d863 (diff) |
Fix issues when attempting to appeal an old strike (#17554)
* Display an error when an appeal could not be submitted * Do not offer users to appeal old strikes * Fix 500 error when trying to appeal a strike that is too old * Avoid using an extra translatable string
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/appeal.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/appeal.rb b/app/models/appeal.rb index 46f35ae37..1f32cfa8b 100644 --- a/app/models/appeal.rb +++ b/app/models/appeal.rb @@ -16,6 +16,8 @@ # updated_at :datetime not null # class Appeal < ApplicationRecord + MAX_STRIKE_AGE = 20.days + belongs_to :account belongs_to :strike, class_name: 'AccountWarning', foreign_key: 'account_warning_id' belongs_to :approved_by_account, class_name: 'Account', optional: true @@ -53,6 +55,6 @@ class Appeal < ApplicationRecord private def validate_time_frame - errors.add(:base, I18n.t('strikes.errors.too_late')) if Time.now.utc > (strike.created_at + 20.days) + errors.add(:base, I18n.t('strikes.errors.too_late')) if strike.created_at < MAX_STRIKE_AGE.ago end end |