diff --git a/app/views/cms/view.rhtml b/app/views/cms/view.rhtml
index 80e9cd9..43ae572 100644
--- a/app/views/cms/view.rhtml
+++ b/app/views/cms/view.rhtml
@@ -7,9 +7,9 @@
<% if !@article or !@article.blog? %>
<%= button :newfolder, _('New folder'), :action => 'new', :type => 'Folder', :parent_id => parent_id %>
+ <%= button('upload-file', _('Upload files'), :action => 'upload_files', :parent_id => parent_id) %>
<% end %>
<%= lightbox_button('new', label_for_new_article(@article), :action => 'new', :parent_id => parent_id) %>
- <%= button('upload-file', _('Upload files'), :action => 'upload_files', :parent_id => parent_id) %>
<%= button(:back, _('Back to control panel'), :controller => 'profile_editor', :action => "index") %>
<% end %>
diff --git a/app/views/content_viewer/view_page.rhtml b/app/views/content_viewer/view_page.rhtml
index 4fed9ac..8ab75b8 100644
--- a/app/views/content_viewer/view_page.rhtml
+++ b/app/views/content_viewer/view_page.rhtml
@@ -44,7 +44,7 @@
<% if !@page.display_as_gallery? %>
<%= lightbox_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) %>
<% end %>
- <% if @page.folder? || (@page.parent && @page.parent.folder?) %>
+ <% if (@page.folder? && !@page.blog?) || (@page.parent && @page.parent.folder? && !@page.parent.blog?) %>
<%= button('upload-file', _('Upload files'), profile.admin_url.merge(:controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent))) %>
<% end %>
<% end %>
diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb
index 5f18631..be9ebb6 100644
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -1111,4 +1111,14 @@ class CmsControllerTest < Test::Unit::TestCase
get :index, :profile => p.identifier
assert_no_tag :tag => 'a', :attributes => {:href => "/myprofile/#{p.identifier}/cms/publish/#{a.id}"}
end
+
+ should 'not offer to upload files to blog' do
+ profile.articles << Blog.new(:name => 'blog test', :profile => profile)
+
+ profile.articles.reload
+ assert profile.has_blog?
+
+ get :view, :profile => profile.identifier, :id => profile.blog.id
+ assert_no_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/upload_files?parent_id=#{profile.blog.id}"}
+ end
end
diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb
index fe890c5..3d32356 100644
--- a/test/functional/content_viewer_controller_test.rb
+++ b/test/functional/content_viewer_controller_test.rb
@@ -821,4 +821,18 @@ class ContentViewerControllerTest < Test::Unit::TestCase
assert_template 'profile/index'
end
+ should "not display 'Upload files' when viewing blog" do
+ login_as(profile.identifier)
+ b = Blog.create!(:name => 'article folder', :profile => profile)
+ get :view_page, :profile => profile.identifier, :page => b.explode_path
+ assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/}
+ end
+
+ should "not display 'Upload files' when viewing post from a blog" do
+ login_as(profile.identifier)
+ b = Blog.create!(:name => 'article folder', :profile => profile)
+ blog_post = TextileArticle.create!(:name => 'children-article', :profile => profile, :parent => b)
+ get :view_page, :profile => profile.identifier, :page => blog_post.explode_path
+ assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/}
+ end
end
--
libgit2 0.21.2