summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-08-03 00:53:35 +0200
committererdgeist <erdgeist@erdgeist.org>2026-08-03 00:53:35 +0200
commit751261c2ffdc90e93869192555ae0d5e4070ff79 (patch)
tree5023240ca3a10653fe560a259d0e46e6c6a7240f /app
parentf2f2b31832ec320889f2178e7e08838723961a14 (diff)
Display stale accounts in users#index
Diffstat (limited to 'app')
-rw-r--r--app/models/user.rb10
-rw-r--r--app/views/users/_user.html.erb9
2 files changed, 19 insertions, 0 deletions
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
10 include Authentication::ByPassword 10 include Authentication::ByPassword
11 11
12 ROLES = %w[redaktion admin alumni].freeze 12 ROLES = %w[redaktion admin alumni].freeze
13 STALE_AMBER_YEARS = 3
14 STALE_RED_YEARS = 10
13 15
14 # Validations 16 # Validations
15 validates_presence_of :login 17 validates_presence_of :login
@@ -243,6 +245,14 @@ class User < ApplicationRecord
243 true 245 true
244 end 246 end
245 247
248 def staleness_tier(now = Time.zone.now)
249 return nil if alumni?
250 return :never if last_login_at.nil?
251
252 return :red if last_login_at <= now - STALE_RED_YEARS.years
253 return :amber if roles.any? && last_login_at <= now - STALE_AMBER_YEARS.years
254 nil
255 end
246 private 256 private
247 257
248 def roles_are_known 258 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 @@
15 <%= icon("shield-off", library: "tabler", "aria-hidden": true) %> 15 <%= icon("shield-off", library: "tabler", "aria-hidden": true) %>
16 </span> 16 </span>
17 <% end %> 17 <% end %>
18 <% if (tier = user.staleness_tier) %>
19 <% hint = tier == :never ? t(".stale_never")
20 : t(".stale_#{tier}", :year => user.last_login_at.year) %>
21 <span role="img" class="stale_flag stale_flag_<%= tier %>"
22 title="<%= hint %>" aria-label="<%= hint %>">
23 <%= icon(tier == :amber ? "clock-exclamation" : "alert-triangle",
24 library: "tabler", "aria-hidden": true) %>
25 </span>
26 <% end %>
18 </span> 27 </span>
19 <%= user.login %> 28 <%= user.login %>
20 </td> 29 </td>