diff --git a/app/models/block.rb b/app/models/block.rb
index 8807194..a9d4fc0 100644
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -40,7 +40,7 @@ class Block < ActiveRecord::Base
if context[:article]
return context[:article] != owner.home_page
else
- return context[:request_path] != '/' + owner.identifier
+ return context[:request_path] != '/' + (owner.kind_of?(Profile) ? owner.identifier : '')
end
end
end
@@ -153,4 +153,19 @@ class Block < ActiveRecord::Base
}
end
+ DISPLAY_OPTIONS = {
+ 'always' => __('In all pages'),
+ 'home_page_only' => __('Only in the homepage'),
+ 'except_home_page' => __('In all pages, except in the homepage'),
+ 'never' => __('Don\'t display'),
+ }
+
+ def display_options
+ DISPLAY_OPTIONS.keys
+ end
+
+ def display_option_label(option)
+ DISPLAY_OPTIONS[option]
+ end
+
end
diff --git a/app/models/main_block.rb b/app/models/main_block.rb
index 3b2bd10..8e2ed59 100644
--- a/app/models/main_block.rb
+++ b/app/models/main_block.rb
@@ -17,11 +17,15 @@ class MainBlock < Block
end
def editable?
- false
+ true
end
def cacheable?
- false
+ false
+ end
+
+ def display_options
+ ['always', 'except_home_page']
end
end
diff --git a/app/views/box_organizer/edit.rhtml b/app/views/box_organizer/edit.rhtml
index bc11bed..a5b76c5 100644
--- a/app/views/box_organizer/edit.rhtml
+++ b/app/views/box_organizer/edit.rhtml
@@ -9,17 +9,11 @@
<%= labelled_form_field _('Display this block:'), '' %>
- <%= radio_button(:block, :display, 'always') %>
- <%= label_tag('block_display_always', _('In all pages')) %>
-
- <%= radio_button(:block, :display, 'home_page_only') %>
- <%= label_tag('block_display_home_page_only', _('Only in the homepage')) %>
-
- <%= radio_button(:block, :display, 'except_home_page') %>
- <%= label_tag('block_display_except_home_page', _('In all pages, except in the homepage')) %>
-
- <%= radio_button(:block, :display, 'never') %>
- <%= label_tag('block_display_never', _("Don't display")) %>
+ <% @block.display_options.each do |option| %>
+ <%= radio_button(:block, :display, option) %>
+ <%= label_tag("block_display_#{option}", _(@block.display_option_label(option))) %>
+
+ <% end %>
<%= labelled_form_field(_('Show for:'), select(:block, :language, [ [ _('all languages'), 'all']] + environment.locales.map {|key, value| [value, key]} )) %>
diff --git a/test/functional/profile_design_controller_test.rb b/test/functional/profile_design_controller_test.rb
index f0104a5..522c565 100644
--- a/test/functional/profile_design_controller_test.rb
+++ b/test/functional/profile_design_controller_test.rb
@@ -300,6 +300,27 @@ class ProfileDesignControllerTest < ActionController::TestCase
assert !@controller.instance_variable_get('@side_block_types').include?(CustomBlock8)
end
+ should 'not edit main block with never option' do
+ get :edit, :profile => 'designtestuser', :id => @b4.id
+ assert_no_tag :input, :attributes => { :type => 'radio', :value => 'never'}
+ end
+
+ should 'not edit main block with home_page_only option' do
+ get :edit, :profile => 'designtestuser', :id => @b4.id
+ assert_no_tag :input, :attributes => { :type => 'radio', :value => 'home_page_only'}
+ end
+
+ should 'edit main block with always option' do
+ get :edit, :profile => 'designtestuser', :id => @b4.id
+ assert_tag :input, :attributes => { :type => 'radio', :value => 'always'}
+ end
+
+ should 'edit main block with except_home_page option' do
+ get :edit, :profile => 'designtestuser', :id => @b4.id
+ assert_tag :input, :attributes => { :type => 'radio', :value => 'except_home_page'}
+ end
+
+
######################################################
# END - tests for BoxOrganizerController features
######################################################
diff --git a/test/unit/main_block_test.rb b/test/unit/main_block_test.rb
index 69ff681..0a84be2 100644
--- a/test/unit/main_block_test.rb
+++ b/test/unit/main_block_test.rb
@@ -11,8 +11,8 @@ class MainBlockTest < ActiveSupport::TestCase
ok("MainBlock must not have a content") { MainBlock.new.content.blank? }
end
- should 'not be editable' do
- assert !MainBlock.new.editable?
+ should 'be editable' do
+ assert MainBlock.new.editable?
end
end
--
libgit2 0.21.2