Commit 515b68a050717f35df592eaba093c6012da3e54d
1 parent
80cbe729
Exists in
master
and in
29 other branches
ActionItem682: don't query for profile, but for the block owner
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/branches/0.11.x@2520 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
24 additions
and
3 deletions
Show diff stats
app/helpers/boxes_helper.rb
... | ... | @@ -151,13 +151,14 @@ module BoxesHelper |
151 | 151 | buttons << icon_button(:down, _('Move block down'), { :action => 'move_block_down' ,:id => block.id }, { :method => 'post'}) |
152 | 152 | end |
153 | 153 | |
154 | + holder = block.owner | |
154 | 155 | # move to opposite side |
155 | 156 | # FIXME too much hardcoded stuff |
156 | - if profile.layout_template == 'default' | |
157 | + if holder.layout_template == 'default' | |
157 | 158 | if block.box.position == 2 # area 2, left side => move to right side |
158 | - buttons << icon_button('right', _('Move to the opposite side'), { :action => 'move_block', :target => 'end-of-box-' + profile.boxes[2].id.to_s, :id => block.id }, :method => 'post' ) | |
159 | + buttons << icon_button('right', _('Move to the opposite side'), { :action => 'move_block', :target => 'end-of-box-' + holder.boxes[2].id.to_s, :id => block.id }, :method => 'post' ) | |
159 | 160 | elsif block.box.position == 3 # area 3, right side => move to left side |
160 | - buttons << icon_button('left', _('Move to the opposite side'), { :action => 'move_block', :target => 'end-of-box-' + profile.boxes[1].id.to_s, :id => block.id }, :method => 'post' ) | |
161 | + buttons << icon_button('left', _('Move to the opposite side'), { :action => 'move_block', :target => 'end-of-box-' + holder.boxes[1].id.to_s, :id => block.id }, :method => 'post' ) | |
161 | 162 | end |
162 | 163 | end |
163 | 164 | ... | ... |
app/models/environment.rb
... | ... | @@ -306,6 +306,14 @@ class Environment < ActiveRecord::Base |
306 | 306 | self[:theme] || 'default' |
307 | 307 | end |
308 | 308 | |
309 | + def layout_template | |
310 | + settings[:layout_template] || 'default' | |
311 | + end | |
312 | + | |
313 | + def layout_template=(value) | |
314 | + settings[:layout_template] = value | |
315 | + end | |
316 | + | |
309 | 317 | def enterprise_template |
310 | 318 | Enterprise.find_by_id settings[:enterprise_template_id] |
311 | 319 | end | ... | ... |
test/functional/environment_design_controller_test.rb
... | ... | @@ -48,6 +48,9 @@ class EnvironmentDesignControllerTest < Test::Unit::TestCase |
48 | 48 | end |
49 | 49 | |
50 | 50 | should 'create back link to environment control panel' do |
51 | + Environment.default.boxes.create!.blocks << CommunitiesBlock.new | |
52 | + Environment.default.boxes.create!.blocks << EnterprisesBlock.new | |
53 | + Environment.default.boxes.create!.blocks << LoginBlock.new | |
51 | 54 | login_as(create_admin_user(Environment.default)) |
52 | 55 | get :index |
53 | 56 | ... | ... |
test/unit/environment_test.rb
... | ... | @@ -419,4 +419,13 @@ class EnvironmentTest < Test::Unit::TestCase |
419 | 419 | assert_equal true, e.disable_ssl |
420 | 420 | end |
421 | 421 | |
422 | + should 'have a layout template' do | |
423 | + e = Environment.new(:layout_template => 'mytemplate') | |
424 | + assert_equal 'mytemplate', e.layout_template | |
425 | + end | |
426 | + | |
427 | + should 'have a default layout template' do | |
428 | + assert_equal 'default', Environment.new.layout_template | |
429 | + end | |
430 | + | |
422 | 431 | end | ... | ... |