Changes to models ok'd (and suggested as temporary solution) by TomH
References #1777
15 files changed:
@relation = Relation.find(params[:id])
@relation = Relation.find(params[:id])
-
- @name = @relation.tags['name'].to_s
- if @name.length == 0:
- @name = "#" + @relation.id.to_s
- end
-
- @title = 'Relation | ' + (@name)
- @next = Relation.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @relation.id }] )
- @prev = Relation.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @relation.id }] )
+ @next = Relation.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @relation.id }] )
+ @prev = Relation.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @relation.id }] )
rescue ActiveRecord::RecordNotFound
@type = "relation"
render :action => "not_found", :status => :not_found
rescue ActiveRecord::RecordNotFound
@type = "relation"
render :action => "not_found", :status => :not_found
def relation_history
@relation = Relation.find(params[:id])
def relation_history
@relation = Relation.find(params[:id])
-
- @name = @relation.tags['name'].to_s
- if @name.length == 0:
- @name = "#" + @relation.id.to_s
- end
-
- @title = 'Relation History | ' + (@name)
rescue ActiveRecord::RecordNotFound
@type = "relation"
render :action => "not_found", :status => :not_found
end
rescue ActiveRecord::RecordNotFound
@type = "relation"
render :action => "not_found", :status => :not_found
end
@way = Way.find(params[:id])
@way = Way.find(params[:id])
-
- @name = @way.tags['name'].to_s
- if @name.length == 0:
- @name = "#" + @way.id.to_s
- end
-
- @title = 'Way | ' + (@name)
- @next = Way.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @way.id }] )
- @prev = Way.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @way.id }] )
+ @next = Way.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @way.id }] )
+ @prev = Way.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @way.id }] )
rescue ActiveRecord::RecordNotFound
@type = "way"
render :action => "not_found", :status => :not_found
end
rescue ActiveRecord::RecordNotFound
@type = "way"
render :action => "not_found", :status => :not_found
end
@way = Way.find(params[:id])
@way = Way.find(params[:id])
-
- @name = @way.tags['name'].to_s
- if @name.length == 0:
- @name = "#" + @way.id.to_s
- end
-
- @title = 'Way History | ' + (@name)
rescue ActiveRecord::RecordNotFound
@type = "way"
render :action => "not_found", :status => :not_found
end
rescue ActiveRecord::RecordNotFound
@type = "way"
render :action => "not_found", :status => :not_found
end
@node = Node.find(params[:id])
@node = Node.find(params[:id])
-
- @name = @node.tags_as_hash['name'].to_s
- if @name.length == 0:
- @name = "#" + @node.id.to_s
- end
-
- @title = 'Node | ' + (@name)
- @next = Node.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @node.id }] )
- @prev = Node.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @node.id }] )
+ @next = Node.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @node.id }] )
+ @prev = Node.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @node.id }] )
rescue ActiveRecord::RecordNotFound
@type = "node"
render :action => "not_found", :status => :not_found
end
rescue ActiveRecord::RecordNotFound
@type = "node"
render :action => "not_found", :status => :not_found
end
@node = Node.find(params[:id])
@node = Node.find(params[:id])
-
- @name = @node.tags_as_hash['name'].to_s
- if @name.length == 0:
- @name = "#" + @node.id.to_s
- end
-
- @title = 'Node History | ' + (@name)
rescue ActiveRecord::RecordNotFound
@type = "way"
render :action => "not_found", :status => :not_found
rescue ActiveRecord::RecordNotFound
@type = "way"
render :action => "not_found", :status => :not_found
def link_to_page(page, page_param)
return link_to(page, page_param => page)
end
def link_to_page(page, page_param)
return link_to(page, page_param => page)
end
+
+ def printable_name(object, version=false)
+ name = object.id.to_s
+ if version
+ name = "#{name}, v#{object.version.to_s}"
+ end
+ if object.tags.include? 'name'
+ name = "#{object.tags['name'].to_s} (#{name})"
+ end
+ return name
+ end
set_primary_keys :id, :version, :sequence_id
belongs_to :relation, :foreign_key=> :id
set_primary_keys :id, :version, :sequence_id
belongs_to :relation, :foreign_key=> :id
+ # A bit messy, referring to the current tables, should do for the data browser for now
+ belongs_to :member, :polymorphic => true
set_primary_keys :id, :version, :sequence_id
belongs_to :way, :foreign_key=> :id
set_primary_keys :id, :version, :sequence_id
belongs_to :way, :foreign_key=> :id
+
+ # A bit messy, referring to current nodes, should do for the data browser for now
+ belongs_to :node
<td>
<table cellpadding="0">
<% @nodes.each do |node| %>
<td>
<table cellpadding="0">
<% @nodes.each do |node| %>
- <tr><td><%= link_to "Node #{node.id.to_s}, version #{node.version.to_s}", :action => "node", :id => node.id.to_s %></td></tr>
+ <tr><td><%= link_to h(printable_name(node, true)), :action => "node", :id => node.id.to_s %></td></tr>
<td>
<table cellpadding="0">
<% @ways.each do |way| %>
<td>
<table cellpadding="0">
<% @ways.each do |way| %>
- <tr><td><%= link_to "Way #{way.id.to_s}, version #{way.version.to_s}", :action => "way", :id => way.id.to_s %></td></tr>
+ <tr><td><%= link_to h(printable_name(way, true)), :action => "way", :id => way.id.to_s %></td></tr>
<% end %>
<%=
#render :partial => "containing_relation", :collection => changeset_details.containing_relation_members
<% end %>
<%=
#render :partial => "containing_relation", :collection => changeset_details.containing_relation_members
<td>
<table cellpadding="0">
<% @relations.each do |relation| %>
<td>
<table cellpadding="0">
<% @relations.each do |relation| %>
- <tr><td><%= link_to "Relation #{relation.id.to_s}, version #{relation.version.to_s}", :action => "relation", :id => relation.id.to_s %></td></tr>
+ <tr><td><%= link_to h(printable_name(relation, true)), :action => "relation", :id => relation.id.to_s %></td></tr>
- <%= link_to "Relation " + containing_relation.relation.id.to_s, :action => "relation", :id => containing_relation.relation.id.to_s %>
+ <%= link_to "Relation " + h(printable_name(containing_relation.relation)), :action => "relation", :id => containing_relation.relation.id.to_s %>
<% unless containing_relation.member_role.blank? %>
(as <%= h(containing_relation.member_role) %>)
<% end %>
<% unless containing_relation.member_role.blank? %>
(as <%= h(containing_relation.member_role) %>)
<% end %>
<td>
<table cellpadding="0">
<% node_details.ways.each do |way| %>
<td>
<table cellpadding="0">
<% node_details.ways.each do |way| %>
- <tr><td><%= link_to "Way " + way.id.to_s, :action => "way", :id => way.id.to_s %></td></tr>
+ <tr><td><%= link_to h(printable_name(way)), :action => "way", :id => way.id.to_s %></td></tr>
<% end %>
<%= render :partial => "containing_relation", :collection => node_details.containing_relation_members %>
</table>
<% end %>
<%= render :partial => "containing_relation", :collection => node_details.containing_relation_members %>
</table>
<tr>
<td>
<%= relation_member.member_type.capitalize %>
<tr>
<td>
<%= relation_member.member_type.capitalize %>
- <%= link_to relation_member.member_id.to_s, :action => relation_member.member_type.downcase, :id => relation_member.member_id %>
+ <%= link_to h(printable_name(relation_member.member)), :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s %>
<% unless relation_member.member_role.blank? %>
as
<%= h(relation_member.member_role) %>
<% unless relation_member.member_role.blank? %>
as
<%= h(relation_member.member_role) %>
<td>
<table cellpadding="0">
<% way_details.way_nodes.each do |wn| %>
<td>
<table cellpadding="0">
<% way_details.way_nodes.each do |wn| %>
- <tr><td><%= link_to "Node " + wn.node_id.to_s, :action => "node", :id => wn.node_id.to_s %></td></tr>
+ <tr><td><%= link_to h(printable_name(wn.node)), :action => "node", :id => wn.node_id.to_s %></td></tr>
+<%
+@name = printable_name @node
+@title = 'Node | ' + @name
+%>
<table width="100%">
<tr>
<td>
<table width="100%">
<tr>
<td>
+<%
+@name = printable_name @node
+@title = 'Node History | ' + @name
+%>
<h2>Node History: <%= h(@name) %></h2>
<table width="100%">
<h2>Node History: <%= h(@name) %></h2>
<table width="100%">
+<%
+@name = printable_name @relation
+@title = 'Relation | ' + @name
+%>
<table width="100%">
<tr>
<td>
<table width="100%">
<tr>
<td>
+<%
+@name = printable_name @relation
+@title = 'Relation History | ' + @name
+%>
<h2>Relation History: <%= h(@name) %></h2>
<table width="100%">
<h2>Relation History: <%= h(@name) %></h2>
<table width="100%">
+<%
+@name = printable_name @way
+@title = 'Way | ' + @name
+%>
<table width="100%">
<tr>
<td>
<table width="100%">
<tr>
<td>
+<%
+@name = printable_name @way
+@title = 'Way History | ' + @name
+%>
<h2>Way History: <%= h(@name) %></h2>
<table width="100%">
<h2>Way History: <%= h(@name) %></h2>
<table width="100%">