Commit 128862a2f876aabafb77d63ea6735da3dadd36b7

Authored by JoenioCosta
1 parent d0645bf0

ActionItem427: display message for disabled enterprises


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2030 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/environment.rb
@@ -131,6 +131,14 @@ class Environment < ActiveRecord::Base @@ -131,6 +131,14 @@ class Environment < ActiveRecord::Base
131 ! self.settings['terms_of_use'].nil? 131 ! self.settings['terms_of_use'].nil?
132 end 132 end
133 133
  134 + def message_for_disabled_enterprise
  135 + self.settings['message_for_disabled_enterprise']
  136 + end
  137 +
  138 + def message_for_disabled_enterprise=(value)
  139 + self.settings['message_for_disabled_enterprise'] = value
  140 + end
  141 +
134 # returns the approval method used for this environment. Possible values are: 142 # returns the approval method used for this environment. Possible values are:
135 # 143 #
136 # Defaults to <tt>:admim</tt>. 144 # Defaults to <tt>:admim</tt>.
app/views/content_viewer/view_page.rhtml
@@ -48,6 +48,12 @@ @@ -48,6 +48,12 @@
48 </div> 48 </div>
49 <% end %> 49 <% end %>
50 50
  51 +<% unless profile.enabled? %>
  52 + <div id='profile-disabled'>
  53 + <%= environment.message_for_disabled_enterprise %>
  54 + </div>
  55 +<% end %>
  56 +
51 <%= @page.to_html %> 57 <%= @page.to_html %>
52 58
53 <div id="article-cat"> 59 <div id="article-cat">
app/views/profile/index.rhtml
  1 +<% unless profile.enabled? %>
  2 + <div id='profile-disabled'>
  3 + <%= environment.message_for_disabled_enterprise %>
  4 + </div>
  5 +<% end %>
  6 +
1 <h2><%= _("%s's profile") % profile.identifier %></h2> 7 <h2><%= _("%s's profile") % profile.identifier %></h2>
2 8
3 <ul> 9 <ul>
public/images/icons-app/README
@@ -43,6 +43,7 @@ gtk-folder.png Nuovo @@ -43,6 +43,7 @@ gtk-folder.png Nuovo
43 epiphany-bookmarks.png dlg-neu 43 epiphany-bookmarks.png dlg-neu
44 mozilla-mail.png dlg-neu 44 mozilla-mail.png dlg-neu
45 gtk-cancel.png dlg-neu 45 gtk-cancel.png dlg-neu
  46 +emblem-important.png dlg-neu
46 ### END OF ICONS LISTING ### 47 ### END OF ICONS LISTING ###
47 48
48 Icons rasterization 49 Icons rasterization
public/images/icons-app/alert.png 0 → 120000
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +emblem-important.png
0 \ No newline at end of file 2 \ No newline at end of file
public/images/icons-app/emblem-important.png 0 → 100644

2.16 KB

public/stylesheets/common.css
@@ -91,6 +91,17 @@ div#errorExplanation h2 { @@ -91,6 +91,17 @@ div#errorExplanation h2 {
91 color: #555; 91 color: #555;
92 } 92 }
93 93
  94 +div#profile-disabled {
  95 + border: 2px solid #944;
  96 + text-align: center;
  97 + margin: auto;
  98 + padding: 5px;
  99 + padding-left: 60px;
  100 + min-height: 40px;
  101 + width: 400px;
  102 + background: url("../images/icons-app/alert.png") no-repeat 5px #ffffa9;
  103 +}
  104 +
94 /*********************************************************/ 105 /*********************************************************/
95 106
96 107
test/functional/content_viewer_controller_test.rb
@@ -259,4 +259,11 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase @@ -259,4 +259,11 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
259 assert_response 404 259 assert_response 404
260 end 260 end
261 261
  262 + should 'show message for disabled enterprises' do
  263 + login_as(@profile.identifier)
  264 + ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false)
  265 + get :view_page, :profile => ent.identifier, :page => []
  266 + assert_tag :tag => 'div', :attributes => { :id => 'profile-disabled' }, :content => Environment.default.message_for_disabled_enterprise
  267 + end
  268 +
262 end 269 end
test/functional/profile_controller_test.rb
@@ -213,4 +213,11 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -213,4 +213,11 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
213 assert_no_tag :tag => 'a', :content => 'Add friend' 213 assert_no_tag :tag => 'a', :content => 'Add friend'
214 end 214 end
215 215
  216 + should 'show message for disabled enterprises' do
  217 + login_as(@profile.identifier)
  218 + ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false)
  219 + get :index, :profile => ent.identifier
  220 + assert_tag :tag => 'div', :attributes => { :id => 'profile-disabled' }, :content => Environment.default.message_for_disabled_enterprise
  221 + end
  222 +
216 end 223 end
test/unit/environment_test.rb
@@ -295,4 +295,10 @@ class EnvironmentTest &lt; Test::Unit::TestCase @@ -295,4 +295,10 @@ class EnvironmentTest &lt; Test::Unit::TestCase
295 assert_not_includes env.people, ent 295 assert_not_includes env.people, ent
296 end 296 end
297 297
  298 + should 'have a message_for_disabled_enterprise attribute' do
  299 + env = Environment.new
  300 + env.message_for_disabled_enterprise = 'this enterprise was disabled'
  301 + assert_equal 'this enterprise was disabled', env.message_for_disabled_enterprise
  302 + end
  303 +
298 end 304 end