From 886712eaf02d5abe7e1e4f762c22293392a234af Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sat, 4 Nov 2023 21:58:04 +0300 Subject: [PATCH] Show unredacted element history --- app/views/browse/_common_details.html.erb | 6 ++- app/views/browse/_node.html.erb | 6 +-- app/views/browse/_relation.html.erb | 6 +-- app/views/browse/_way.html.erb | 6 +-- config/locales/en.yml | 1 + test/controllers/browse_controller_test.rb | 49 ++++++++++++++++++++++ 6 files changed, 64 insertions(+), 10 deletions(-) diff --git a/app/views/browse/_common_details.html.erb b/app/views/browse/_common_details.html.erb index 7d3f8e829..195332b09 100644 --- a/app/views/browse/_common_details.html.erb +++ b/app/views/browse/_common_details.html.erb @@ -1,5 +1,9 @@

- <%= t "browse.version" %> + <%= if common_details.redacted? + t "browse.redacted_version" + else + t "browse.version" + end %> #<%= link_to_unless_current common_details.version, :controller => "old_#{@type.pluralize}", :action => :show, :version => common_details.version %>

diff --git a/app/views/browse/_node.html.erb b/app/views/browse/_node.html.erb index 6c6c1fdf3..e395a4283 100644 --- a/app/views/browse/_node.html.erb +++ b/app/views/browse/_node.html.erb @@ -1,4 +1,4 @@ -<% if node.redacted? %> +<% if node.redacted? && !params[:show_redactions] %>
<%= t "browse.redacted.message_html", :type => t("browse.redacted.type.node"), @@ -7,7 +7,7 @@ :id => node.redaction.id), node.redaction) %>
<% else %> -
+ <%= tag.div :class => ["browse-section", "browse-node", { "text-muted" => node.redacted? }] do %> <%= render :partial => "browse/common_details", :object => node %> <% unless node.ways.empty? and node.containing_relation_members.empty? %> @@ -31,5 +31,5 @@ <% end %> <% end %> -
+ <% end %> <% end %> diff --git a/app/views/browse/_relation.html.erb b/app/views/browse/_relation.html.erb index c513ea6d1..922e642cc 100644 --- a/app/views/browse/_relation.html.erb +++ b/app/views/browse/_relation.html.erb @@ -1,4 +1,4 @@ -<% if relation.redacted? %> +<% if relation.redacted? && !params[:show_redactions] %>
<%= t "browse.redacted.message_html", :type => t("browse.redacted.type.relation"), @@ -7,7 +7,7 @@ :id => relation.redaction.id), relation.redaction) %>
<% else %> -
+ <%= tag.div :class => ["browse-section", "browse-relation", { "text-muted" => relation.redacted? }] do %> <%= render :partial => "browse/common_details", :object => relation %> <% unless relation.containing_relation_members.empty? %> @@ -29,5 +29,5 @@ <% end %> -
+ <% end %> <% end %> diff --git a/app/views/browse/_way.html.erb b/app/views/browse/_way.html.erb index 7197298ac..d93321a0f 100644 --- a/app/views/browse/_way.html.erb +++ b/app/views/browse/_way.html.erb @@ -1,4 +1,4 @@ -<% if way.redacted? %> +<% if way.redacted? && !params[:show_redactions] %>
<%= t "browse.redacted.message_html", :type => t("browse.redacted.type.way"), @@ -7,7 +7,7 @@ :id => way.redaction.id), way.redaction) %>
<% else %> -
+ <%= tag.div :class => ["browse-section", "browse-way", { "text-muted" => way.redacted? }] do %> <%= render :partial => "browse/common_details", :object => way %> <% unless way.containing_relation_members.empty? %> @@ -39,5 +39,5 @@ <% end %> -
+ <% end %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index a674487a6..32f54387f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -317,6 +317,7 @@ en: deleted_ago_by_html: "Deleted %{time_ago} by %{user}" edited_ago_by_html: "Edited %{time_ago} by %{user}" version: "Version" + redacted_version: "Redacted Version" in_changeset: "Changeset" anonymous: "anonymous" no_comment: "(no comment)" diff --git a/test/controllers/browse_controller_test.rb b/test/controllers/browse_controller_test.rb index a6fd3ef8d..312caca51 100644 --- a/test/controllers/browse_controller_test.rb +++ b/test/controllers/browse_controller_test.rb @@ -193,6 +193,21 @@ class BrowseControllerTest < ActionDispatch::IntegrationTest assert_select ".browse-section.browse-node .longitude", 0 end + def test_redacted_node_unredacted_history + session_for(create(:moderator_user)) + node = create(:node, :with_history, :deleted, :version => 2) + node_v1 = node.old_nodes.find_by(:version => 1) + node_v1.redact!(create(:redaction)) + + get node_history_path(:id => node, :params => { :show_redactions => true }) + assert_response :success + assert_template "browse/history" + + assert_select ".browse-section", 2 + assert_select ".browse-section.browse-redacted", 0 + assert_select ".browse-section.browse-node", 2 + end + def test_redacted_way_history way = create(:way, :with_history, :version => 4) way_v1 = way.old_ways.find_by(:version => 1) @@ -211,6 +226,23 @@ class BrowseControllerTest < ActionDispatch::IntegrationTest assert_select ".browse-section.browse-way", 2 end + def test_redacted_way_unredacted_history + session_for(create(:moderator_user)) + way = create(:way, :with_history, :version => 4) + way_v1 = way.old_ways.find_by(:version => 1) + way_v1.redact!(create(:redaction)) + way_v3 = way.old_ways.find_by(:version => 3) + way_v3.redact!(create(:redaction)) + + get way_history_path(:id => way, :params => { :show_redactions => true }) + assert_response :success + assert_template "browse/history" + + assert_select ".browse-section", 4 + assert_select ".browse-section.browse-redacted", 0 + assert_select ".browse-section.browse-way", 4 + end + def test_redacted_relation_history relation = create(:relation, :with_history, :version => 4) relation_v1 = relation.old_relations.find_by(:version => 1) @@ -229,6 +261,23 @@ class BrowseControllerTest < ActionDispatch::IntegrationTest assert_select ".browse-section.browse-relation", 2 end + def test_redacted_relation_unredacted_history + session_for(create(:moderator_user)) + relation = create(:relation, :with_history, :version => 4) + relation_v1 = relation.old_relations.find_by(:version => 1) + relation_v1.redact!(create(:redaction)) + relation_v3 = relation.old_relations.find_by(:version => 3) + relation_v3.redact!(create(:redaction)) + + get relation_history_path(:id => relation, :params => { :show_redactions => true }) + assert_response :success + assert_template "browse/history" + + assert_select ".browse-section", 4 + assert_select ".browse-section.browse-redacted", 0 + assert_select ".browse-section.browse-relation", 4 + end + def test_query get query_path assert_response :success -- 2.39.5