From 4680be4632fcc22048a5746057ff30002cfa85bf Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Tue, 12 Mar 2024 12:32:20 +0000 Subject: [PATCH] feat: add unconfirmed status --- app/helpers/tag_helper.rb | 2 ++ app/models/user.rb | 10 ++++++++++ app/views/users/_user_list.html.erb | 2 +- app/views/users/show.html.erb | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/helpers/tag_helper.rb b/app/helpers/tag_helper.rb index e2a3ec92d..3cb02b769 100644 --- a/app/helpers/tag_helper.rb +++ b/app/helpers/tag_helper.rb @@ -14,6 +14,7 @@ module TagHelper deactivated: "Deactivated", deleted: "Deleted", merged: "Merged", + unconfirmed: "Unconfirmed", }.freeze COLOUR = { @@ -29,6 +30,7 @@ module TagHelper deactivated: "grey", deleted: "red", merged: "orange", + unconfirmed: "red", }.freeze def status_tag(status, classes = []) diff --git a/app/models/user.rb b/app/models/user.rb index 0fc21172a..25599da56 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -237,6 +237,16 @@ class User < ApplicationRecord active_unread_notifications.last end + def status + if active == false + :deactivated + elsif confirmed? == false + :unconfirmed + else + :active + end + end + protected # Checks whether a password is needed or not. For validations only. diff --git a/app/views/users/_user_list.html.erb b/app/views/users/_user_list.html.erb index dccf83c2a..19e206b03 100644 --- a/app/views/users/_user_list.html.erb +++ b/app/views/users/_user_list.html.erb @@ -50,7 +50,7 @@ <% end %> <% end %> <% row.with_cell(text: simple_format(org_cell(user), {}, wrapper_tag: "div")) %> - <% row.with_cell(text: user.active? ? user.last_sign_in_at&.to_formatted_s(:govuk_date) : status_tag(:deactivated)) %> + <% row.with_cell(text: user.active? ? user.last_sign_in_at&.to_formatted_s(:govuk_date) : status_tag(user.status)) %> <%= govuk_link_to users_path(user) do %> User <%= user.id %> <% end %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index ce2b6ee71..13cdda462 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -115,7 +115,7 @@ <%= summary_list.with_row do |row| row.with_key { "Status" } - row.with_value { status_tag(@user.active? ? :active : :deactivated) } + row.with_value { status_tag(@user.status) } row.with_action end %> <% end %>