Browse Source

feat: add unconfirmed status

pull/2307/head
natdeanlewissoftwire 2 years ago
parent
commit
4680be4632
  1. 2
      app/helpers/tag_helper.rb
  2. 10
      app/models/user.rb
  3. 2
      app/views/users/_user_list.html.erb
  4. 2
      app/views/users/show.html.erb

2
app/helpers/tag_helper.rb

@ -14,6 +14,7 @@ module TagHelper
deactivated: "Deactivated", deactivated: "Deactivated",
deleted: "Deleted", deleted: "Deleted",
merged: "Merged", merged: "Merged",
unconfirmed: "Unconfirmed",
}.freeze }.freeze
COLOUR = { COLOUR = {
@ -29,6 +30,7 @@ module TagHelper
deactivated: "grey", deactivated: "grey",
deleted: "red", deleted: "red",
merged: "orange", merged: "orange",
unconfirmed: "red",
}.freeze }.freeze
def status_tag(status, classes = []) def status_tag(status, classes = [])

10
app/models/user.rb

@ -237,6 +237,16 @@ class User < ApplicationRecord
active_unread_notifications.last active_unread_notifications.last
end end
def status
if active == false
:deactivated
elsif confirmed? == false
:unconfirmed
else
:active
end
end
protected protected
# Checks whether a password is needed or not. For validations only. # Checks whether a password is needed or not. For validations only.

2
app/views/users/_user_list.html.erb

@ -50,7 +50,7 @@
<% end %> <% end %>
<% end %> <% end %>
<% row.with_cell(text: simple_format(org_cell(user), {}, wrapper_tag: "div")) %> <% 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 %> <%= govuk_link_to users_path(user) do %>
<span class="govuk-visually-hidden">User </span><%= user.id %> <span class="govuk-visually-hidden">User </span><%= user.id %>
<% end %> <% end %>

2
app/views/users/show.html.erb

@ -115,7 +115,7 @@
<%= summary_list.with_row do |row| <%= summary_list.with_row do |row|
row.with_key { "Status" } row.with_key { "Status" }
row.with_value { status_tag(@user.active? ? :active : :deactivated) } row.with_value { status_tag(@user.status) }
row.with_action row.with_action
end %> end %>
<% end %> <% end %>

Loading…
Cancel
Save