]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5095'
authorTom Hughes <tom@compton.nu>
Mon, 19 Aug 2024 18:05:44 +0000 (19:05 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 19 Aug 2024 18:05:44 +0000 (19:05 +0100)
app/assets/javascripts/index/directions.js
app/controllers/user_blocks_controller.rb
app/views/user_blocks/_navigation.html.erb
app/views/user_blocks/new.html.erb
config/locales/en.yml
test/controllers/user_blocks_controller_test.rb

index 04298d125ebbf2aa6c019b8d855e1872a17783ac..7e8c18fb8cdaafd6d0d0ace0542a8a780d5eadb3 100644 (file)
@@ -75,6 +75,7 @@ OSM.Directions = function (map) {
 
   $(".directions_form .btn-close").on("click", function (e) {
     e.preventDefault();
+    $(".describe_location").toggle(!endpoints[0].value);
     $(".search_form input[name='query']").val(endpoints[0].value);
     OSM.router.route("/" + OSM.formatHash(map));
   });
index 962eff04ce06306cb97906d9d4a0edf2c126e4bc..ae6e3c1cd5f4f3b7fc26646cd8ae346ebdb75cb1 100644 (file)
@@ -72,6 +72,7 @@ class UserBlocksController < ApplicationController
         @user_block.reason = params[:user_block][:reason]
         @user_block.needs_view = params[:user_block][:needs_view]
         @user_block.ends_at = Time.now.utc + @block_period.hours
+        @user_block.revoker = current_user if user_block_was_active && !@user_block.active?
         if !user_block_was_active && @user_block.active?
           flash.now[:error] = t(".inactive_block_cannot_be_reactivated")
           render :action => "edit"
index f4f9b04f82b4794e58d13f2f4f6c1e31486ba1d5..061989586a255b067cdcf94d219feb7d8b06df86 100644 (file)
                   :class => ["nav-link", { :active => action_name == "blocks_by" }] %>
     </li>
   <% end %>
-  <% if @user_block %>
+  <% if @user_block&.persisted? %>
     <li class="nav-item">
       <%= link_to t(".block", :id => @user_block.id),
                   user_block_path(@user_block),
                   :class => "nav-link active" %>
     </li>
+  <% elsif @user_block&.new_record? %>
+    <li class="nav-item">
+      <%= link_to t(".new_block"),
+                  new_user_block_path,
+                  :class => "nav-link active" %>
+    </li>
   <% end %>
 </ul>
index 3de6aa539ec86d48964524437641f1ca86b5f07f..14eaff2b9aa43b485e6ba1c4f4d1e5ebbe9f54f7 100644 (file)
@@ -1,7 +1,11 @@
 <% @title = t ".title", :name => @user.display_name %>
+
+<% content_for :heading_class, "pb-0" %>
 <% content_for :heading do %>
   <h1><%= t(".heading_html", :name => link_to(@user.display_name, @user)) %></h1>
+  <%= render :partial => "navigation" %>
 <% end %>
+
 <%= bootstrap_form_for(@user_block) do |f| %>
   <%= hidden_field_tag "display_name", @user.display_name, :autocomplete => "off" %>
   <%= f.richtext_field :reason, :cols => 80, :rows => 20 %>
@@ -18,5 +22,4 @@
   <% end %>
 
   <%= f.primary %>
-  <%= link_to t(".back"), user_blocks_path, :class => "btn btn-link" %>
 <% end %>
index a97eca9c016c3104d6697596a29e5cbb74404820..30721562a8098459436b18ab8cdb2b72de741fa3 100644 (file)
@@ -2936,7 +2936,6 @@ en:
       title: "Creating block on %{name}"
       heading_html: "Creating block on %{name}"
       period: "How long, starting now, the user will be blocked from the API for."
-      back: "View all blocks"
     edit:
       title: "Editing block on %{name}"
       heading_html: "Editing block on %{name}"
@@ -3034,6 +3033,7 @@ en:
       blocks_by_me: "Blocks by Me"
       blocks_by_user: "Blocks by %{user}"
       block: "Block #%{id}"
+      new_block: "New Block"
   user_mutes:
     index:
       title: "Muted Users"
index e6782a64d0d3910393c70b026f1350b738211e3e..696d3c8d04fb3400fcda186289a4dce30c6d4a95 100644 (file)
@@ -493,6 +493,28 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
     check_inactive_block_updates(block)
   end
 
+  ##
+  # test the update action revoking the block
+  def test_revoke_using_update
+    moderator_user = create(:moderator_user)
+    block = create(:user_block, :creator => moderator_user)
+
+    session_for(moderator_user)
+    put user_block_path(block,
+                        :user_block_period => "24",
+                        :user_block => { :needs_view => false, :reason => "Updated Reason" })
+    block.reload
+    assert_predicate block, :active?
+    assert_nil block.revoker
+
+    put user_block_path(block,
+                        :user_block_period => "0",
+                        :user_block => { :needs_view => false, :reason => "Updated Reason" })
+    block.reload
+    assert_not_predicate block, :active?
+    assert_equal moderator_user, block.revoker
+  end
+
   ##
   # test the revoke action
   def test_revoke