From 32865b528d2f3f95e91186bf8867e6b2b89c1f0b Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 2 Jul 2022 12:53:14 +0200 Subject: [PATCH] Highlight current ban --- app/models/user_ban.rb | 4 ++++ app/views/modal/ban/_history.haml | 4 ++-- config/locales/views.en.yml | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/user_ban.rb b/app/models/user_ban.rb index 7f1a5c30..65ee8df3 100644 --- a/app/models/user_ban.rb +++ b/app/models/user_ban.rb @@ -7,4 +7,8 @@ class UserBan < ApplicationRecord def permanent? expires_at.nil? end + + def current? + permanent? || expires_at > Time.now.utc + end end diff --git a/app/views/modal/ban/_history.haml b/app/views/modal/ban/_history.haml index a0076c82..72d1e811 100644 --- a/app/views/modal/ban/_history.haml +++ b/app/views/modal/ban/_history.haml @@ -2,13 +2,13 @@ %p= t '.count', user: user.screen_name, count: user.bans.count .list-group - user.bans.each do |ban| - .list-group-item + .list-group-item{ class: ban.current? ? 'list-group-item-success' : '' } .d-flex.w-100.justify-content-between %h5.mb-1= ban.reason %small.text-muted= time_ago_in_words ban.created_at - if ban.banned_by.present? %p= t('.issued_by', user: ban.banned_by.screen_name) - if ban.expires_at.present? - %small= t('.until', until: ban.expires_at.strftime('%Y-%m-%d %H:%M:%S')) + %small= t(ban.expires_at.past? ? '.expired' : '.until', until: ban.expires_at.strftime('%Y-%m-%d %H:%M:%S')) - else %small= t('.permanent') diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index c07013ee..9f7cd598 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -101,6 +101,7 @@ en: issued_by: "Issued by %{user}" permanent: "Permanent" until: "Until %{until}" + expired: "Expired at %{until}" services: index: title: "Service Settings"