]> git.openstreetmap.org Git - rails.git/commitdiff
Always get the bug commenter name from the user if there is one
authorTom Hughes <tom@compton.nu>
Sat, 7 May 2011 16:47:05 +0000 (17:47 +0100)
committerTom Hughes <tom@compton.nu>
Sat, 7 May 2011 16:47:05 +0000 (17:47 +0100)
app/models/map_bug_comment.rb
app/views/map_bugs/_bug.xml.builder
app/views/map_bugs/rss.rss.builder

index 3b95b1fff5565dfe486f8039f71824670fbbbc3c..50bfe3bef40c6af44ae3cc69f03e09f70a24a37b 100644 (file)
@@ -9,4 +9,12 @@ class MapBugComment < ActiveRecord::Base
   validates_uniqueness_of :id
   validates_presence_of :visible
   validates_presence_of :date_created
   validates_uniqueness_of :id
   validates_presence_of :visible
   validates_presence_of :date_created
+
+  def commenter_name
+    if self.commenter_id.nil?
+      self.read_attribute(:commenter_name)
+    else
+      self.user.display_name
+    end
+  end
 end
 end
index 69683b7ddad92cb92b7020f89c0c6c6d4370851b..a25a588a2460b2426455ea72883556fa7b99d5b2 100644 (file)
@@ -12,14 +12,8 @@ xml.bug("lon" => bug.lon, "lat" => bug.lat) do
     bug.map_bug_comment.each do |comment|
       xml.comment do
         xml.date comment.date_created
     bug.map_bug_comment.each do |comment|
       xml.comment do
         xml.date comment.date_created
-
-        unless comment.commenter_id.nil?
-          xml.uid comment.commenter_id
-          xml.user comment.user.display_name   
-        else
-          xml.user comment.commenter_name
-        end
-
+        xml.uid comment.commenter_id unless comment.commenter_id.nil?
+        xml.user comment.commenter_name
         xml.text comment.comment
       end      
     end
         xml.text comment.comment
       end      
     end
index f5b597dd7699a51ae52d45548f2f2a78b6cdec42..ced183a10b61a32367a6d8da6fbeae89a4cebc17 100644 (file)
@@ -35,13 +35,7 @@ xml.rss("version" => "2.0",
         description_text += comment.map_bug.flatten_comment("<br>", comment.date_created)
 
         xml.description description_text 
         description_text += comment.map_bug.flatten_comment("<br>", comment.date_created)
 
         xml.description description_text 
-
-        if comment.user.nil?
-          xml.author comment.commenter_name
-        else
-          xml.author comment.user.display_name
-        end
-               
+        xml.author comment.commenter_name
         xml.pubDate comment.date_created.to_s(:rfc822)
         xml.geo :lat, comment.map_bug.lat
         xml.geo :long, comment.map_bug.lon
         xml.pubDate comment.date_created.to_s(:rfc822)
         xml.geo :lat, comment.map_bug.lat
         xml.geo :long, comment.map_bug.lon