diff --git a/app/models/community_user.rb b/app/models/community_user.rb index e81d1f5797e6dc4e2012e492e6b0fc1c364ab2be..ee9e90fd7e9341ef57817455d14dd0a5794bd600 100644 --- a/app/models/community_user.rb +++ b/app/models/community_user.rb @@ -30,6 +30,10 @@ class CommunityUser < ApplicationRecord false end + def latest_warning + mod_warnings&.order(created_at: 'desc').first.created_at + end + # Calculation functions for privilege scores # These are quite expensive, so we'll cache them for a while def post_score diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index bb10e0ec4b0c0b8c2d42443cd18ed9f6c2f81284..493d19b4917ab756c9d8f7e15f7b146078502f4c 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -20,6 +20,14 @@ </div> <% end %> +<% if moderator? && @user.community_user.mod_warnings&.size.positive? %> +<div class="notice is-info h-m-b-4"> + <p><%= pluralize(@user.community_user.mod_warnings.count, 'message') %> sent, + most recent: <%= time_ago_in_words(@user.community_user.latest_warning) %> ago + </p> +</div> +<% end %> + <div class="grid <%= deleted_user?(@user) ? 'deleted-content' : '' %>"> <div class="grid--cell is-9-lg is-12"> <div class="h-p-0 h-p-t-0">