Move generation of gpx_file XML from model to builder

This commit is contained in:
Frederik Ramm 2019-04-13 01:44:15 +02:00 committed by Tom Hughes
parent 15841e8d2a
commit 17e6e69c39
6 changed files with 64 additions and 43 deletions

View file

@ -0,0 +1,22 @@
# basic attributes
attrs = {
"id" => trace.id,
"name" => trace.name,
"user" => trace.user.display_name,
"visibility" => trace.visibility,
"pending" => trace.inserted ? "false" : "true",
"timestamp" => trace.timestamp.xmlschema
}
if trace.inserted
attrs["lat"] = trace.latitude.to_s
attrs["lon"] = trace.longitude.to_s
end
xml.gpx_file(attrs) do |trace_xml_node|
trace_xml_node.description(trace.description)
trace.tags.each do |t|
trace_xml_node.tag(t.tag)
end
end

View file

@ -0,0 +1,9 @@
xml.instruct! :xml, :version => "1.0"
# basic attributes
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
@traces.each do |trace|
osm << render(:partial => "api/traces/trace.builder", :locals => { :trace => trace })
end
end