Include description and tags in GPX details API response
authorTom Hughes <tom@compton.nu>
Mon, 11 Oct 2010 18:10:42 +0000 (19:10 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 11 Oct 2010 18:10:42 +0000 (19:10 +0100)
app/models/trace.rb

index 24f9323..39ecb41 100644 (file)
@@ -149,12 +149,23 @@ class Trace < ActiveRecord::Base
     el1 = XML::Node.new 'gpx_file'
     el1['id'] = self.id.to_s
     el1['name'] = self.name.to_s
-    el1['lat'] = self.latitude.to_s
-    el1['lon'] = self.longitude.to_s
+    el1['lat'] = self.latitude.to_s if self.inserted
+    el1['lon'] = self.longitude.to_s if self.inserted
     el1['user'] = self.user.display_name
     el1['visibility'] = self.visibility
     el1['pending'] = (!self.inserted).to_s
     el1['timestamp'] = self.timestamp.xmlschema
+
+    el2 = XML::Node.new 'description'
+    el2 << self.description
+    el1 << el2
+
+    self.tags.each do |tag|
+      el2 = XML::Node.new('tag')
+      el2 << tag.tag
+      el1 << el2
+    end
+
     return el1
   end