From 751261c2ffdc90e93869192555ae0d5e4070ff79 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 3 Aug 2026 00:53:35 +0200 Subject: Display stale accounts in users#index --- app/models/user.rb | 10 ++++++++++ app/views/users/_user.html.erb | 9 +++++++++ 2 files changed, 19 insertions(+) (limited to 'app') diff --git a/app/models/user.rb b/app/models/user.rb index 49c22584..adfdc564 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,6 +10,8 @@ class User < ApplicationRecord include Authentication::ByPassword ROLES = %w[redaktion admin alumni].freeze + STALE_AMBER_YEARS = 3 + STALE_RED_YEARS = 10 # Validations validates_presence_of :login @@ -243,6 +245,14 @@ class User < ApplicationRecord true end + def staleness_tier(now = Time.zone.now) + return nil if alumni? + return :never if last_login_at.nil? + + return :red if last_login_at <= now - STALE_RED_YEARS.years + return :amber if roles.any? && last_login_at <= now - STALE_AMBER_YEARS.years + nil + end private def roles_are_known diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index d944fff0..37009027 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -15,6 +15,15 @@ <%= icon("shield-off", library: "tabler", "aria-hidden": true) %> <% end %> + <% if (tier = user.staleness_tier) %> + <% hint = tier == :never ? t(".stale_never") + : t(".stale_#{tier}", :year => user.last_login_at.year) %> + + <%= icon(tier == :amber ? "clock-exclamation" : "alert-triangle", + library: "tabler", "aria-hidden": true) %> + + <% end %> <%= user.login %> -- cgit v1.3