$(".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));
});
@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"
: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>
<% @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 %>
<% end %>
<%= f.primary %>
- <%= link_to t(".back"), user_blocks_path, :class => "btn btn-link" %>
<% end %>
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}"
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"
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