Add `permanently_banned?` method to user model

This commit is contained in:
Karina Kwiatek 2022-06-26 15:48:25 +02:00 committed by Karina Kwiatek
parent cd168df9b2
commit 73274988c1
2 changed files with 6 additions and 2 deletions

View File

@ -229,6 +229,10 @@ class User < ApplicationRecord
end
# endregion
def permanently_banned?
bans.current.first&.permanent? || false
end
def banned?
self.bans.current.count > 0
end

View File

@ -14,8 +14,8 @@
.modal-body
= f.check_box :ban, label: t('views.modal.bancontrol.ban'), checked: user.banned?
#ban-controls{ class: user.banned? ? '' : 'd-none' }
= f.check_box :permaban, label: t('views.modal.bancontrol.permanent'), checked: user.permanent?
#ban-controls-time{ class: user.permanent? ? 'd-none' : '' }
= f.check_box :permaban, label: t('views.modal.bancontrol.permanent'), checked: user.permanently_banned?
#ban-controls-time{ class: user.permanently_banned? ? 'd-none' : '' }
= f.text_field :duration, label: '', required: true
.form-check.form-check-inline
= f.radio_button :duration_unit, 'hours', label: 'Hours', checked: true