From caf49bb25d94f370cbd4ef9b3033e7f319aa6eaa Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Tue, 5 Sep 2023 13:35:08 +0300 Subject: [PATCH] Show user id on profile pages to moderators and admins --- app/views/users/show.html.erb | 4 ++++ config/locales/en.yml | 1 + test/controllers/users_controller_test.rb | 2 ++ 3 files changed, 7 insertions(+) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 6335b06d9..81fda926b 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -131,6 +131,10 @@ <% end -%> <% end -%> + <% if current_user&.moderator? || current_user&.administrator? %> +
<%= t ".uid" %>
+
<%= link_to @user.id, api_user_path(:id => @user.id) %>
+ <% end -%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 2fc8f8196..ec845dc7c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2697,6 +2697,7 @@ en: remove as friend: Unfriend add as friend: Add Friend mapper since: "Mapper since:" + uid: "User id:" ct status: "Contributor terms:" ct undecided: Undecided ct declined: Declined diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 9358a5948..402129d32 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -495,6 +495,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0 assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0 + assert_select "a[href='/api/0.6/user/#{ERB::Util.u(user.id)}']", 0 end # Login as a moderator @@ -512,6 +513,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0 assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 1 + assert_select "a[href='/api/0.6/user/#{ERB::Util.u(user.id)}']", 1 end end -- 2.39.5