From: Anton Khorev Date: Thu, 25 Jul 2024 01:05:31 +0000 (+0300) Subject: Show edit links for revoked blocks to revokers X-Git-Tag: live~344^2~2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/d88cb014cb21ab88419eb48045d3daec96ec9093?ds=sidebyside;hp=58ac035d4198759acdf49707145b474cf182e897 Show edit links for revoked blocks to revokers --- diff --git a/app/views/user_blocks/_block.html.erb b/app/views/user_blocks/_block.html.erb index 461dc7a8d..a18d1dbdb 100644 --- a/app/views/user_blocks/_block.html.erb +++ b/app/views/user_blocks/_block.html.erb @@ -15,7 +15,8 @@ <% end %> <%= link_to t(".show"), block %> - <% if current_user and current_user.id == block.creator_id %><%= link_to t(".edit"), edit_user_block_path(block) %><% end %> + <% if current_user && (current_user.id == block.creator_id || + current_user.id == block.revoker_id) %><%= link_to t(".edit"), edit_user_block_path(block) %><% end %> <% if show_revoke_link %> <% if block.active? %><%= link_to t(".revoke"), revoke_user_block_path(block) %><% end %> <% end %> diff --git a/app/views/user_blocks/show.html.erb b/app/views/user_blocks/show.html.erb index 619cd6c3f..c36c043cf 100644 --- a/app/views/user_blocks/show.html.erb +++ b/app/views/user_blocks/show.html.erb @@ -26,9 +26,12 @@
<%= @user_block.reason.to_html %>
-<% if current_user&.id == @user_block.creator_id || can?(:revoke, UserBlock) && @user_block.active? %> +<% if current_user && (current_user.id == @user_block.creator_id || + current_user.id == @user_block.revoker_id) || + can?(:revoke, UserBlock) && @user_block.active? %>
- <% if current_user&.id == @user_block.creator_id %> + <% if current_user && (current_user.id == @user_block.creator_id || + current_user.id == @user_block.revoker_id) %> <%= link_to t(".edit"), edit_user_block_path(@user_block), :class => "btn btn-outline-primary" %> <% end %> <% if can?(:revoke, UserBlock) && @user_block.active? %> diff --git a/test/controllers/user_blocks_controller_test.rb b/test/controllers/user_blocks_controller_test.rb index dd0b1287b..d164d6aef 100644 --- a/test/controllers/user_blocks_controller_test.rb +++ b/test/controllers/user_blocks_controller_test.rb @@ -212,7 +212,7 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest check_block_buttons block, :edit => 1 session_for(revoker_user) - check_block_buttons block + check_block_buttons block, :edit => 1 end private