Commit 1cad93396d1066a3d7352e3fc6e0537f536c5452
1 parent
75e83af7
Exists in
master
and in
22 other branches
Revert "Added a filter to display blocks depending on user"
This reverts commit 22d3d9d34034136b344cd6b58270a6b49bf61dbd. Conflicts: public/stylesheets/application.css test/functional/environment_design_controller_test.rb
Showing
6 changed files
with
3 additions
and
80 deletions
Show diff stats
app/helpers/boxes_helper.rb
| @@ -70,18 +70,7 @@ module BoxesHelper | @@ -70,18 +70,7 @@ module BoxesHelper | ||
| 70 | end | 70 | end |
| 71 | 71 | ||
| 72 | def select_blocks(arr, context) | 72 | def select_blocks(arr, context) |
| 73 | - filter = (context && context[:params] && context[:params][:filter]) || {} | ||
| 74 | - user_filter(arr, filter) | ||
| 75 | - end | ||
| 76 | - | ||
| 77 | - def user_filter(arr, filter) | ||
| 78 | - if filter[:display_user]=='not_logged' | ||
| 79 | - arr.select { |block| block.display_to_user?(nil) } | ||
| 80 | - elsif filter[:display_user]=='logged' | ||
| 81 | - arr.select { |block| block.display_to_user?(user) } | ||
| 82 | - else | ||
| 83 | - arr | ||
| 84 | - end | 73 | + arr |
| 85 | end | 74 | end |
| 86 | 75 | ||
| 87 | def display_block(block, main_content = nil) | 76 | def display_block(block, main_content = nil) |
app/views/box_organizer/index.rhtml
| @@ -4,11 +4,3 @@ | @@ -4,11 +4,3 @@ | ||
| 4 | <%= colorbox_button('add', _('Add a block'), { :action => 'add_block' }) %> | 4 | <%= colorbox_button('add', _('Add a block'), { :action => 'add_block' }) %> |
| 5 | <%= button(:back, _('Back to control panel'), :controller => (profile.nil? ? 'admin_panel': 'profile_editor')) %> | 5 | <%= button(:back, _('Back to control panel'), :controller => (profile.nil? ? 'admin_panel': 'profile_editor')) %> |
| 6 | <% end %> | 6 | <% end %> |
| 7 | - | ||
| 8 | -<% form_tag({:action => :index}) do %> | ||
| 9 | - <div class="user-filter"> | ||
| 10 | - <span class="label"><%= _('Display blocks to:') %> </span> | ||
| 11 | - <%= select_tag('filter[display_user]', options_from_collection_for_select(Block.new.display_user_options, :first, :last, params[:filter] ? params[:filter][:display_user] : 'all'), :onchange => "this.form.submit();") %> | ||
| 12 | - </div> | ||
| 13 | - <div style="clear: both"></div> | ||
| 14 | -<% end %> |
public/stylesheets/application.css
| @@ -6512,14 +6512,6 @@ ul.article-versions li { | @@ -6512,14 +6512,6 @@ ul.article-versions li { | ||
| 6512 | padding: 3px 0px; | 6512 | padding: 3px 0px; |
| 6513 | } | 6513 | } |
| 6514 | 6514 | ||
| 6515 | -.user-filter { | ||
| 6516 | - float: right; | ||
| 6517 | -} | ||
| 6518 | - | ||
| 6519 | -.design-menu { | ||
| 6520 | - float: left; | ||
| 6521 | -} | ||
| 6522 | - | ||
| 6523 | /* * * Admin manage fields * * */ | 6515 | /* * * Admin manage fields * * */ |
| 6524 | 6516 | ||
| 6525 | .controller-features .manage-fields-batch-actions, | 6517 | .controller-features .manage-fields-batch-actions, |
test/functional/environment_design_controller_test.rb
| @@ -370,18 +370,6 @@ class EnvironmentDesignControllerTest < ActionController::TestCase | @@ -370,18 +370,6 @@ class EnvironmentDesignControllerTest < ActionController::TestCase | ||
| 370 | assert @controller.instance_variable_get('@side_block_types').include?(CustomBlock8) | 370 | assert @controller.instance_variable_get('@side_block_types').include?(CustomBlock8) |
| 371 | end | 371 | end |
| 372 | 372 | ||
| 373 | - should 'display user filter for blocks' do | ||
| 374 | - login_as(create_admin_user(Environment.default)) | ||
| 375 | - get :index | ||
| 376 | - assert_tag 'div', :attributes => {:class => 'user-filter'} | ||
| 377 | - end | ||
| 378 | - | ||
| 379 | - should 'display user filter for blocks with selected value' do | ||
| 380 | - login_as(create_admin_user(Environment.default)) | ||
| 381 | - get :index, :filter => {:display_user => 'logged'} | ||
| 382 | - assert_tag 'select', :attributes => {:name => 'filter[display_user]'}, :descendant => {:tag => 'option', :attributes => {:value => 'logged', :selected => true}} | ||
| 383 | - end | ||
| 384 | - | ||
| 385 | should 'clone a block' do | 373 | should 'clone a block' do |
| 386 | login_as(create_admin_user(Environment.default)) | 374 | login_as(create_admin_user(Environment.default)) |
| 387 | block = TagsBlock.create! | 375 | block = TagsBlock.create! |
test/functional/profile_design_controller_test.rb
| @@ -744,9 +744,4 @@ class ProfileDesignControllerTest < ActionController::TestCase | @@ -744,9 +744,4 @@ class ProfileDesignControllerTest < ActionController::TestCase | ||
| 744 | end | 744 | end |
| 745 | end | 745 | end |
| 746 | 746 | ||
| 747 | - should 'display user filter for blocks' do | ||
| 748 | - get :index, :profile => 'designtestuser' | ||
| 749 | - assert_tag 'div', :attributes => {:class => 'user-filter'} | ||
| 750 | - end | ||
| 751 | - | ||
| 752 | end | 747 | end |
test/unit/boxes_helper_test.rb
| @@ -54,7 +54,6 @@ class BoxesHelperTest < ActiveSupport::TestCase | @@ -54,7 +54,6 @@ class BoxesHelperTest < ActiveSupport::TestCase | ||
| 54 | expects(:display_block).with(b, '') | 54 | expects(:display_block).with(b, '') |
| 55 | stubs(:request).returns(request) | 55 | stubs(:request).returns(request) |
| 56 | stubs(:block_target).returns('') | 56 | stubs(:block_target).returns('') |
| 57 | - stubs(:user).returns(nil) | ||
| 58 | expects(:locale).returns('en') | 57 | expects(:locale).returns('en') |
| 59 | with_box_decorator self do | 58 | with_box_decorator self do |
| 60 | display_box_content(box, '') | 59 | display_box_content(box, '') |
| @@ -74,7 +73,6 @@ class BoxesHelperTest < ActiveSupport::TestCase | @@ -74,7 +73,6 @@ class BoxesHelperTest < ActiveSupport::TestCase | ||
| 74 | box.save! | 73 | box.save! |
| 75 | expects(:display_block).with(b, '').never | 74 | expects(:display_block).with(b, '').never |
| 76 | stubs(:request).returns(request) | 75 | stubs(:request).returns(request) |
| 77 | - stubs(:user).returns(nil) | ||
| 78 | stubs(:block_target).returns('') | 76 | stubs(:block_target).returns('') |
| 79 | expects(:locale).returns('en') | 77 | expects(:locale).returns('en') |
| 80 | display_box_content(box, '') | 78 | display_box_content(box, '') |
| @@ -107,47 +105,16 @@ class BoxesHelperTest < ActiveSupport::TestCase | @@ -107,47 +105,16 @@ class BoxesHelperTest < ActiveSupport::TestCase | ||
| 107 | assert block_css_classes(Block.new(:display => 'never')).split.any? { |item| item == 'invisible-block'} | 105 | assert block_css_classes(Block.new(:display => 'never')).split.any? { |item| item == 'invisible-block'} |
| 108 | end | 106 | end |
| 109 | 107 | ||
| 110 | - should 'fill context with the article, request_path, user and locale' do | 108 | + should 'fill context with the article, request_path and locale' do |
| 111 | request = mock() | 109 | request = mock() |
| 112 | box = Box.create!(:owner => fast_create(Profile)) | 110 | box = Box.create!(:owner => fast_create(Profile)) |
| 113 | request.expects(:path).returns('/') | 111 | request.expects(:path).returns('/') |
| 114 | request.expects(:params).returns({}) | 112 | request.expects(:params).returns({}) |
| 115 | stubs(:request).returns(request) | 113 | stubs(:request).returns(request) |
| 116 | - stubs(:user).returns(nil) | ||
| 117 | expects(:locale).returns('en') | 114 | expects(:locale).returns('en') |
| 118 | - box_decorator.expects(:select_blocks).with([], {:article => nil, :request_path => '/', :locale => 'en', :params => {}, :user => nil}).returns([]) | 115 | + box_decorator.expects(:select_blocks).with([], {:article => nil, :request_path => '/', :locale => 'en', :params => {}}).returns([]) |
| 119 | 116 | ||
| 120 | display_box_content(box, '') | 117 | display_box_content(box, '') |
| 121 | end | 118 | end |
| 122 | 119 | ||
| 123 | - should 'filter blocks by user' do | ||
| 124 | - b1 = Block.new | ||
| 125 | - b2 = Block.new | ||
| 126 | - arr = user_filter([b1, b2], {:display_user => 'all'}) | ||
| 127 | - assert_equivalent [b1, b2], arr | ||
| 128 | - end | ||
| 129 | - | ||
| 130 | - should 'filter blocks by logged user' do | ||
| 131 | - b1 = Block.new(:display_user => 'logged') | ||
| 132 | - b2 = Block.new(:display_user => 'not_logged') | ||
| 133 | - stubs(:user).returns(User.new) | ||
| 134 | - arr = user_filter([b1, b2], {:display_user => 'logged'}) | ||
| 135 | - assert_equivalent [b1], arr | ||
| 136 | - end | ||
| 137 | - | ||
| 138 | - should 'filter blocks by not logged user' do | ||
| 139 | - b1 = Block.new(:display_user => 'logged') | ||
| 140 | - b2 = Block.new(:display_user => 'not_logged') | ||
| 141 | - stubs(:user).returns(User.new) | ||
| 142 | - arr = user_filter([b1, b2], {:display_user => 'not_logged'}) | ||
| 143 | - assert_equivalent [b2], arr | ||
| 144 | - end | ||
| 145 | - | ||
| 146 | - should 'select blocks by user filter' do | ||
| 147 | - b = Block.new | ||
| 148 | - expects(:user_filter).once.returns([b]) | ||
| 149 | - arr = select_blocks([], {:psarams => {}}) | ||
| 150 | - assert_equal [b], arr | ||
| 151 | - end | ||
| 152 | - | ||
| 153 | end | 120 | end |