diff --git a/app/models/community_user.rb b/app/models/community_user.rb index e81d1f5797e6dc4e2012e492e6b0fc1c364ab2be..f0a80e60fc035ca7e38489593e46f3a8a0076b88 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..f90c512959e455afd336000a74c25f989a6ce7f1 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -64,14 +64,18 @@ <% end %> <% end %> <% if current_user&.is_moderator %> - <a href="<%= mod_user_path(@user) %>" class="button is-danger is-outlined is-small" data-drop="#mod-tools-drop"><i class="fas fa-shield-alt"></i> Moderator Tools</a> + <a href="<%= mod_user_path(@user) %>" class="button is-danger is-outlined is-small" data-drop="#mod-tools-drop"><i class="fas fa-shield-alt"></i> Moderator Tools <% if @user.community_user.mod_warnings&.size.positive? %> (<%= pluralize(@user.community_user.mod_warnings.count, 'message') %>) <% end %></a> <div class="droppanel" id="mod-tools-drop"> <div class="droppanel--header">quick actions</div> <div class="droppanel--menu"> <a href="/users/<%= @user.id %>/mod/activity-log">full activity log</a> <a href="/users/<%= @user.id %>/mod/annotations">annotations on user</a> <a href="/users/<%= @user.id %>/mod/privileges">privileges</a> - <a href="/warning/log/<%= @user.id %>">warnings and suspensions sent to user <% if @user.community_user.suspended? %><em>(includes lifting the suspension)</em><% end %></a> + <a href="/warning/log/<%= @user.id %>">warnings and suspensions sent to user + <% if @user.community_user.suspended? %><em>(includes lifting the suspension)</em> + <% elsif @user.community_user.mod_warnings&.size.positive? %> + (latest <%= time_ago_in_words(@user.community_user.latest_warning) %> ago) + <% end %></a> <a href="/warning/new/<%= @user.id %>">warn or suspend user</a> </div> <div class="h-m-t-6">