From c15a029cb596e47d9ecac86edcc59fdaa6a81155 Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Fri, 15 Aug 2008 14:01:54 +0000 Subject: [PATCH] ActionItem616: stop showing private content on seraches --- app/models/article.rb | 11 +++++++++++ app/models/product.rb | 4 ++++ app/models/profile.rb | 15 +++++++++++++-- app/views/search/_display_results.rhtml | 2 +- test/functional/cms_controller_test.rb | 12 ++++++++++++ test/unit/article_test.rb | 41 +++++++++++++++++++++++++++++++++++++++++ test/unit/product_test.rb | 12 ++++++++++++ test/unit/profile_test.rb | 16 ++++++++++++++++ 8 files changed, 110 insertions(+), 3 deletions(-) diff --git a/app/models/article.rb b/app/models/article.rb index 06145af..f62769c 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -42,6 +42,13 @@ class Article < ActiveRecord::Base pending_categorizations.clear end + before_save do |article| + if article.parent + article.public_article = article.parent.public_article + end + true + end + acts_as_taggable N_('Tag list') @@ -156,6 +163,10 @@ class Article < ActiveRecord::Base !cat.is_a?(ProductCategory) end + def public? + profile.public? && public_article + end + private def sanitize_tag_list diff --git a/app/models/product.rb b/app/models/product.rb index 0304166..798b3e4 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -63,4 +63,8 @@ class Product < ActiveRecord::Base enterprise.generate_url(:controller => 'catalog', :action => 'show', :id => id) end + def public? + enterprise.public_profile + end + end diff --git a/app/models/profile.rb b/app/models/profile.rb index 6db0a78..38aa5ed 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -304,16 +304,24 @@ class Profile < ActiveRecord::Base false end - after_create :insert_default_homepage_and_feed - def insert_default_homepage_and_feed + after_create :insert_default_article_set + def insert_default_article_set + # a default homepage hp = default_homepage(:name => _("%s's home page") % self.name, :body => _("

This is a default homepage created for %s. It can be changed though the control panel.

") % self.name, :advertise => false) hp.profile = self hp.save! self.home_page = hp self.save! + # a default rss feed feed = RssFeed.new(:name => 'feed') self.articles << feed + + # a default private folder if public + if self.public? + folder = Folder.new(:name => _("Intranet"), :public_article => false) + self.articles << folder + end end # Adds a person as member of this Profile. @@ -403,4 +411,7 @@ class Profile < ActiveRecord::Base self[:theme] || environment.theme end + def public? + public_profile + end end diff --git a/app/views/search/_display_results.rhtml b/app/views/search/_display_results.rhtml index e3af92f..d6dc105 100644 --- a/app/views/search/_display_results.rhtml +++ b/app/views/search/_display_results.rhtml @@ -38,7 +38,7 @@