From 73274988c1540262abc92c081a804ca3cfa2b1c0 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 26 Jun 2022 15:48:25 +0200 Subject: [PATCH] Add `permanently_banned?` method to user model --- app/models/user.rb | 4 ++++ app/views/modal/_ban.haml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 5bdd3fc0..c6e68b10 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/modal/_ban.haml b/app/views/modal/_ban.haml index e532c822..6bf8c900 100644 --- a/app/views/modal/_ban.haml +++ b/app/views/modal/_ban.haml @@ -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