Highlight current ban

This commit is contained in:
Karina Kwiatek 2022-07-02 12:53:14 +02:00 committed by Karina Kwiatek
parent c838263a2e
commit 32865b528d
3 changed files with 7 additions and 2 deletions

View File

@ -7,4 +7,8 @@ class UserBan < ApplicationRecord
def permanent?
expires_at.nil?
end
def current?
permanent? || expires_at > Time.now.utc
end
end

View File

@ -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')

View File

@ -101,6 +101,7 @@ en:
issued_by: "Issued by %{user}"
permanent: "Permanent"
until: "Until %{until}"
expired: "Expired at %{until}"
services:
index:
title: "Service Settings"