]> git.openstreetmap.org Git - rails.git/commitdiff
Hide diary entries and comments made by deleted users.
authorTom Hughes <tom@compton.nu>
Sun, 12 Oct 2008 18:38:54 +0000 (18:38 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 12 Oct 2008 18:38:54 +0000 (18:38 +0000)
app/controllers/diary_entry_controller.rb
app/models/diary_entry.rb

index b425ef4b6e844ddb6e34d288c74a160bf8ea8414..e0d6e44cdd8764f4aacc39bfcf8d664ca38ee83e 100644 (file)
@@ -69,7 +69,8 @@ class DiaryEntryController < ApplicationController
       end
     else
       @title = "Users' diaries"
-      @entry_pages, @entries = paginate(:diary_entries,
+      @entry_pages, @entries = paginate(:diary_entries, :include => :user,
+                                        :conditions => "users.visible = 1",
                                         :order => 'created_at DESC',
                                         :per_page => 20)
     end
@@ -90,7 +91,9 @@ class DiaryEntryController < ApplicationController
         render :nothing => true, :status => :not_found
       end
     else
-      @entries = DiaryEntry.find(:all, :order => 'created_at DESC', :limit => 20)
+      @entries = DiaryEntry.find(:all, :include => :user,
+                                 :conditions => "users.visible = 1",
+                                 :order => 'created_at DESC', :limit => 20)
       @title = "OpenStreetMap diary entries"
       @description = "Recent diary entries from users of OpenStreetMap"
       @link = "http://www.openstreetmap.org/diary"
index 5b3d34766d06a17e86fc2a61577829c9e7bc8f41..8568160774f8d671dfefd8a8746a5eefbfdd3649 100644 (file)
@@ -1,6 +1,8 @@
 class DiaryEntry < ActiveRecord::Base
   belongs_to :user
-  has_many :diary_comments, :order => "id"
+  has_many :diary_comments, :include => :user,
+                            :conditions => "users.visible = 1",
+                            :order => "id"
 
   validates_presence_of :title, :body
   validates_numericality_of :latitude, :allow_nil => true