From 495f736d1aadeb5c5a582691d826acbd8bcdc08a Mon Sep 17 00:00:00 2001 From: Larissa Reis Date: Mon, 4 Aug 2014 03:01:04 -0300 Subject: [PATCH] spread: only shows spread button if user is logged in and content is public --- app/models/article.rb | 5 ++++- app/views/content_viewer/_article_toolbar.html.erb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/article.rb b/app/models/article.rb index 29b308d..ae138a4 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -507,7 +507,10 @@ class Article < ActiveRecord::Base end alias :allow_delete? :allow_post_content? - alias :allow_spread? :allow_post_content? + + def allow_spread?(user = nil) + user && public? + end def allow_create?(user) allow_post_content?(user) || allow_publish_content?(user) diff --git a/app/views/content_viewer/_article_toolbar.html.erb b/app/views/content_viewer/_article_toolbar.html.erb index 5c1c2d4..aa37706 100644 --- a/app/views/content_viewer/_article_toolbar.html.erb +++ b/app/views/content_viewer/_article_toolbar.html.erb @@ -15,7 +15,7 @@ <%= expirable_button @page, :delete, content, url, options %> <% end %> - <% if !@page.folder? && @page.public? && !remove_content_button(:spread) %> + <% if !@page.folder? && @page.allow_spread?(user) && !remove_content_button(:spread) %> <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page.id }) %> <%= expirable_button @page, :spread, content_tag( 'span', _('Spread this') ), url, {:class => 'colorbox'} if url %> <% end %> -- libgit2 0.21.2