Commit 13d70601fb96c9915631485c59128ed7e196de8e
Committed by
Antonio Terceiro
1 parent
79840d9f
Exists in
master
and in
29 other branches
Adding 'Unblock' button to the disabled enterprise block
* Adding an unblock method for enterprises * Adding the 'lock' icon to icon list * Adding 'block' and 'unblock' noosfero steps. (ActionItem1402)
Showing
10 changed files
with
84 additions
and
3 deletions
Show diff stats
app/controllers/public/profile_controller.rb
... | ... | @@ -113,6 +113,11 @@ class ProfileController < PublicController |
113 | 113 | render :text => '', :layout => false |
114 | 114 | end |
115 | 115 | |
116 | + def unblock | |
117 | + profile.unblock | |
118 | + redirect_to :controller => 'profile', :action => 'index' | |
119 | + end | |
120 | + | |
116 | 121 | protected |
117 | 122 | |
118 | 123 | def check_access_to_profile |
... | ... | @@ -157,4 +162,5 @@ class ProfileController < PublicController |
157 | 162 | def members_per_page |
158 | 163 | 20 |
159 | 164 | end |
165 | + | |
160 | 166 | end | ... | ... |
app/models/disabled_enterprise_message_block.rb
... | ... | @@ -14,7 +14,9 @@ class DisabledEnterpriseMessageBlock < Block |
14 | 14 | |
15 | 15 | def content |
16 | 16 | message = self.owner.environment.message_for_disabled_enterprise || '' |
17 | - content_tag('div', message, :class => 'enterprise-disabled') | |
17 | + lambda do | |
18 | + render :file => 'blocks/disabled_enterprise_message', :locals => {:message => message} | |
19 | + end | |
18 | 20 | end |
19 | 21 | |
20 | 22 | def editable? | ... | ... |
app/models/enterprise.rb
... | ... | @@ -0,0 +1,8 @@ |
1 | +<div id='enterprise-disabled'> | |
2 | + <%= message %> | |
3 | + <% if profile.blocked? && user.is_admin?(profile.environment) %> | |
4 | + <div class='unlock-button'> | |
5 | + <%= button :lock, _('Unblock'), {:controller => 'profile', :action => 'unblock'} %> | |
6 | + </div> | |
7 | + <% end %> | |
8 | +</div> | ... | ... |
features/step_definitions/noosfero_steps.rb
... | ... | @@ -150,3 +150,14 @@ end |
150 | 150 | Given /^"(.+)" is friend of "(.+)"$/ do |person, friend| |
151 | 151 | Person[person].add_friend(Person[friend]) |
152 | 152 | end |
153 | + | |
154 | +Given /^(.+) is blocked$/ do |enterprise_name| | |
155 | + enterprise = Enterprise.find_by_name(enterprise_name) | |
156 | + enterprise.block | |
157 | +end | |
158 | + | |
159 | +Given /^(.+) is disabled$/ do |enterprise_name| | |
160 | + enterprise = Enterprise.find_by_name(enterprise_name) | |
161 | + enterprise.enabled = false | |
162 | + enterprise.save | |
163 | +end | ... | ... |
... | ... | @@ -0,0 +1,34 @@ |
1 | +Feature: unblock button | |
2 | + As an environment administrator | |
3 | + I want to unblock an enterprise | |
4 | + In order to try to activate it again | |
5 | + | |
6 | + Background: | |
7 | + Given the following enterprise | |
8 | + | identifier | name | | |
9 | + | sample-enterprise | Sample Enterprise | | |
10 | + And the following blocks | |
11 | + | owner | type | | |
12 | + | sample-enterprise | DisabledEnterpriseMessageBlock | | |
13 | + And Sample Enterprise is disabled | |
14 | + | |
15 | + Scenario: the environment administrator unblocks a blocked enterprise | |
16 | + Given I am logged in as admin | |
17 | + And Sample Enterprise is blocked | |
18 | + And I am on Sample Enterprise's homepage | |
19 | + When I follow "Unblock" | |
20 | + Then I should not see "Unblock" | |
21 | + | |
22 | + Scenario: a not administrator user can't see "Unblock" button | |
23 | + Given the following user | |
24 | + | login | name | | |
25 | + | joaosilva | Joao Silva | | |
26 | + And I am logged in as "joaosilva" | |
27 | + And Sample Enterprise is blocked | |
28 | + When I am on Sample Enterprise's homepage | |
29 | + Then I should not see "Unblock" | |
30 | + | |
31 | + Scenario: a not blocked enterprise should not show "Unblock" button | |
32 | + Given I am logged in as admin | |
33 | + When I am on Sample Enterprise's homepage | |
34 | + Then I should not see "Unblock" | ... | ... |
public/designs/icons/tango/style.css
... | ... | @@ -68,4 +68,5 @@ |
68 | 68 | .icon-media-play { background-image: url(Tango/16x16/actions/media-playback-start.png) } |
69 | 69 | .icon-media-prev { background-image: url(Tango/16x16/actions/media-skip-backward.png) } |
70 | 70 | .icon-media-next { background-image: url(Tango/16x16/actions/media-skip-forward.png) } |
71 | +.icon-lock { background-image: url(Tango/16x16/actions/lock.png) } | |
71 | 72 | ... | ... |
public/stylesheets/common.css
... | ... | @@ -102,6 +102,10 @@ div#profile-disabled { |
102 | 102 | background: url("../images/icons-app/alert.png") no-repeat 5px #ffffa9; |
103 | 103 | } |
104 | 104 | |
105 | +div#profile-disabled .unlock-button{ | |
106 | + margin: 5px; | |
107 | +} | |
108 | + | |
105 | 109 | .explanation { |
106 | 110 | font-style: italic; |
107 | 111 | font-size: 10px; | ... | ... |
test/unit/disabled_enterprise_message_block_test.rb
... | ... | @@ -14,7 +14,8 @@ class DisabledEnterpriseMessageBlockTest < Test::Unit::TestCase |
14 | 14 | block.expects(:owner).returns(p) |
15 | 15 | p.expects(:environment).returns(e) |
16 | 16 | |
17 | - assert_tag_in_string block.content, :tag => 'div', :content => /This message is for disabled enterprises/ | |
17 | + expects(:render).with(:file => 'blocks/disabled_enterprise_message', :locals => { :message => 'This message is for disabled enterprises'}) | |
18 | + instance_eval(&block.content) | |
18 | 19 | end |
19 | 20 | |
20 | 21 | should 'display nothing if environment has no message' do |
... | ... | @@ -24,7 +25,8 @@ class DisabledEnterpriseMessageBlockTest < Test::Unit::TestCase |
24 | 25 | block.expects(:owner).returns(p) |
25 | 26 | p.expects(:environment).returns(e) |
26 | 27 | |
27 | - assert_no_tag_in_string block.content, :tag => 'div', :content => /This message is for disabled enterprises/ | |
28 | + expects(:render).with(:file => 'blocks/disabled_enterprise_message', :locals => { :message => ''}) | |
29 | + instance_eval(&block.content) | |
28 | 30 | end |
29 | 31 | |
30 | 32 | should 'not be editable' do | ... | ... |
test/unit/enterprise_test.rb
... | ... | @@ -145,6 +145,14 @@ class EnterpriseTest < Test::Unit::TestCase |
145 | 145 | assert Enterprise.find(ent.id).blocked? |
146 | 146 | end |
147 | 147 | |
148 | + should 'unblock' do | |
149 | + ent = Enterprise.create!(:name => 'test enteprise', :identifier => 'test_ent') | |
150 | + ent.data[:blocked] = true | |
151 | + ent.save | |
152 | + ent.unblock | |
153 | + assert !Enterprise.find(ent.id).blocked? | |
154 | + end | |
155 | + | |
148 | 156 | should 'enable and make user admin' do |
149 | 157 | ent = Enterprise.create!(:name => 'test enteprise', :identifier => 'test_ent', :enabled => false) |
150 | 158 | p = create_user('test_user').person | ... | ... |