Don't show coordinates for deleted nodes

This commit is contained in:
Andy Allan 2012-07-11 14:07:50 +01:00 committed by Tom Hughes
parent bda393e7e2
commit 2c67c079ac
7 changed files with 24 additions and 12 deletions

View file

@ -201,11 +201,14 @@ class Node < ActiveRecord::Base
def to_xml_node(changeset_cache = {}, user_display_name_cache = {})
el1 = XML::Node.new 'node'
el1['id'] = self.id.to_s
el1['lat'] = self.lat.to_s
el1['lon'] = self.lon.to_s
el1['version'] = self.version.to_s
el1['changeset'] = self.changeset_id.to_s
if self.visible?
el1['lat'] = self.lat.to_s
el1['lon'] = self.lon.to_s
end
if changeset_cache.key?(self.changeset_id)
# use the cache if available
else

View file

@ -52,8 +52,11 @@ class OldNode < ActiveRecord::Base
el2['v'] = v.to_s
el1 << el2
end
el1['lat'] = self.lat.to_s
el1['lon'] = self.lon.to_s
if self.visible?
el1['lat'] = self.lat.to_s
el1['lon'] = self.lon.to_s
end
el1['changeset'] = self.changeset.id.to_s
if self.changeset.user.data_public?

View file

@ -5,10 +5,12 @@
<%= render :partial => "common_details", :object => node_details %>
<% if node_details.visible -%>
<tr>
<th><%= t 'browse.node_details.coordinates' %></th>
<td><div class="geo"><%= link_to(content_tag(:span, number_with_delimiter(node_details.lat), :class => "latitude") + ", " + content_tag(:span, number_with_delimiter(node_details.lon), :class => "longitude"), {:controller => 'site', :action => 'index', :lat => h(node_details.lat), :lon => h(node_details.lon), :zoom => "18"}) %></div></td>
</tr>
<% end -%>
<% unless node_details.ways.empty? and node_details.containing_relation_members.empty? %>
<tr valign="top">

View file

@ -7,10 +7,13 @@
<% end %>
<%= render :partial => "navigation" %>
<h2><%= t'browse.node.node_title', :node_name => @name %></h2>
<% if @node.visible -%>
<%= render :partial => "map", :object => @node %>
<% end -%>
<%= render :partial => "node_details", :object => @node %>
<hr />
<%= raw t'browse.node.download', :download_xml_link => link_to(t('browse.node.download_xml'), :controller => "old_node", :action => "version", :version => @node.version),
:view_history_link => link_to(t('browse.node.view_history'), :action => "node_history"),
:edit_link => link_to(t('browse.node.edit'), :controller => "site", :action => "edit", :lat => @node.lat, :lon => @node.lon, :zoom => 18, :node => @node.id)
%>
<%= link_to(t('browse.node.download_xml'), :controller => "old_node", :action => "version", :version => @node.version) %>
| <%= link_to(t('browse.node.view_history'), :action => "node_history") %>
<% if @node.visible -%>
| <%= link_to(t('browse.node.edit'), :controller => "site", :action => "edit", :lat => @node.lat, :lon => @node.lon, :zoom => 18, :node => @node.id) %>
<% end -%>

View file

@ -3,7 +3,9 @@
@title = t('browse.node_history.node_history') + ' | ' + @name
%>
<h2><%= raw t'browse.node_history.node_history_title', :node_name => link_to(h(@name), :action => "node", :id => @node.id) %></h2>
<% if @node.visible -%>
<%= render :partial => "map", :object => @node %>
<% end -%>
<% @node.old_nodes.reverse.each do |node| %>
<%= render :partial => "node_details", :object => node %>
<hr />

View file

@ -174,7 +174,6 @@ en:
node:
node: "Node"
node_title: "Node: %{node_name}"
download: "%{download_xml_link}, %{view_history_link} or %{edit_link}"
download_xml: "Download XML"
view_history: "view history"
edit: "edit"

View file

@ -231,9 +231,9 @@ class NodeControllerTest < ActionController::TestCase
assert @response.body.to_i > current_nodes(:public_visible_node).version,
"delete request should return a new version number for node"
# this won't work since the node is already deleted
content(nodes(:invisible_node).to_xml)
delete :delete, :id => current_nodes(:invisible_node).id
# deleting the same node twice doesn't work
content(nodes(:public_visible_node).to_xml)
delete :delete, :id => current_nodes(:public_visible_node).id
assert_response :gone
# this won't work since the node never existed