Browse Source

Merge fbcad0e5b0 into e72707b77e

pull/3331/merge
Nat Dean-Lewis 7 days ago committed by GitHub
parent
commit
ef1c79ebad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/helpers/user_helper.rb
  2. 6
      app/models/user.rb
  3. 1
      app/policies/user_policy.rb
  4. 1
      app/services/exports/user_export_constants.rb
  5. 3
      app/services/exports/user_export_service.rb
  6. 15
      app/views/users/show.html.erb
  7. 3
      spec/fixtures/exports/user.xml

2
app/helpers/user_helper.rb

@ -91,7 +91,7 @@ module UserHelper
end
def user_action_text(user, attribute)
return "Change" if %w[role phone].include?(attribute) && user.send(attribute).present?
return "Change" if attribute == "phone_extension" || (%w[role phone].include?(attribute) && user.send(attribute).present?)
""
end

6
app/models/user.rb

@ -334,12 +334,6 @@ class User < ApplicationRecord
save!(validate: false)
end
def phone_with_extension
return phone if phone_extension.blank?
"#{phone}, Ext. #{phone_extension}"
end
def assigned_to_lettings_logs
lettings_logs.where(assigned_to: self)
end

1
app/policies/user_policy.rb

@ -26,6 +26,7 @@ class UserPolicy
%w[
edit_emails?
edit_telephone_numbers?
edit_extension_numbers?
edit_names?
].each do |method_name|
define_method method_name do

1
app/services/exports/user_export_constants.rb

@ -6,6 +6,7 @@ module Exports::UserExportConstants
"email",
"name",
"phone",
"extension_number",
"organisation_id",
"organisation_name",
"role",

3
app/services/exports/user_export_service.rb

@ -64,7 +64,8 @@ module Exports
attribute_hash["role"] = user.role
attribute_hash["organisation_name"] = user.organisation.name
attribute_hash["active"] = user.active?
attribute_hash["phone"] = [user.phone, user.phone_extension].compact.join(" ")
attribute_hash["phone"] = user.phone
attribute_hash["extension_number"] = user.phone_extension
attribute_hash["last_sign_in_at"] = user.last_sign_in_at&.iso8601
attribute_hash
end

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

@ -65,6 +65,21 @@
end
end %>
<%= summary_list.with_row do |row|
row.with_key { "Extension number" }
row.with_value { user_details_html(@user, current_user, "phone_extension") }
if UserPolicy.new(current_user, @user).edit_extension_numbers?
row.with_action(
text: user_action_text(@user, "phone_extension"),
visually_hidden_text: "extension number",
href: aliased_user_edit(@user, current_user),
html_attributes: { "data-qa": "change-extension-number" },
)
else
row.with_action
end
end %>
<%= summary_list.with_row do |row|
row.with_key { "Password" }
row.with_value { "••••••••" }

3
spec/fixtures/exports/user.xml vendored

@ -8,7 +8,8 @@
<sign_in_count>5</sign_in_count>
<last_sign_in_at>2022-03-03T00:00:00+00:00</last_sign_in_at>
<role>data_provider</role>
<phone>1234512345123 123</phone>
<phone>1234512345123</phone>
<extension_number>123</extension_number>
<is_dpo>false</is_dpo>
<is_key_contact>false</is_key_contact>
<active>true</active>

Loading…
Cancel
Save