Commit e73f1a422e504faec9d224484b69ce2e799a295b

Authored by JoenioCosta
1 parent ae3a5cc3

ActionItem518: display summary of enterprise on initial page

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2158 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/helpers/enterprise_homepage_helper.rb 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +module EnterpriseHomepageHelper
  2 +
  3 + def display_profile_info(profile)
  4 + data = ''
  5 + unless profile.contact_person.blank?
  6 + data << content_tag('strong', _('Contact person: ')) + profile.contact_person + '<br/>'
  7 + end
  8 + unless profile.contact_email.blank?
  9 + data << content_tag('strong', _('E-Mail: ')) + profile.contact_email + '<br/>'
  10 + end
  11 + unless profile.contact_phone.blank?
  12 + data << content_tag('strong', _('Phone(s): ')) + profile.contact_phone + '<br/>'
  13 + end
  14 + unless profile.region.nil?
  15 + data << content_tag('strong', _('Location: ')) + profile.region.name + '<br/>'
  16 + end
  17 + unless profile.address.blank?
  18 + data << content_tag('strong', _('Address: ')) + profile.address + '<br/>'
  19 + end
  20 + unless profile.legal_form.blank?
  21 + data << content_tag('strong', _('Legal form: ')) + profile.legal_form + '<br/>'
  22 + end
  23 + unless profile.foundation_year.blank?
  24 + data << content_tag('strong', _('Foundation year: ')) + profile.foundation_year + '<br/>'
  25 + end
  26 + unless profile.economic_activity.blank?
  27 + data << content_tag('strong', _('Economic activity: ')) + profile.economic_activity + '<br/>'
  28 + end
  29 + if profile.respond_to?(:distance) and !profile.distance.nil?
  30 + data << content_tag('strong', _('Distance: ')) + "%.2f%" % profile.distance + '<br/>'
  31 + end
  32 + content_tag('div', data, :class => 'profile-info')
  33 + end
  34 +
  35 +end
... ...
app/models/enterprise_homepage.rb
... ... @@ -8,8 +8,14 @@ class EnterpriseHomepage &lt; Article
8 8 _('Display the summary of profile.')
9 9 end
10 10  
  11 + # FIXME isn't this too much including just to be able to generate some HTML?
  12 + include ActionView::Helpers::TagHelper
  13 + include ActionView::Helpers::UrlHelper
  14 + include ActionController::UrlWriter
  15 + include ActionView::Helpers::AssetTagHelper
  16 + include EnterpriseHomepageHelper
11 17 def to_html
12   - body || ''
  18 + display_profile_info(self.profile) + content_tag('div', self.body || '')
13 19 end
14 20  
15 21 end
... ...
public/designs/themes/ecosol/stylesheets/controller_content_viewer.css 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +/************* enterprise homepage style *****************/
  2 +
  3 +.profile-info {
  4 + border: none;
  5 + background: #B8CFE7;
  6 + -moz-border-radius: 15px;
  7 + padding: 10px;
  8 +}
... ...
public/stylesheets/controller_cms.css
... ... @@ -122,4 +122,3 @@ div.file-manager-button a:hover {
122 122 .file-manager-small .file-manager-controls * {
123 123 text-align: right;
124 124 }
125   -
... ...
public/stylesheets/controller_content_viewer.css 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +/************* enterprise homepage style *****************/
  2 +
... ...
test/unit/enterprise_homepage_test.rb
... ... @@ -15,12 +15,13 @@ class EnterpriseHomepageTest &lt; Test::Unit::TestCase
15 15 assert_kind_of String, EnterpriseHomepage.description
16 16 end
17 17  
18   - should 'accept empty body' do
19   - a = EnterpriseHomepage.new
20   - a.expects(:body).returns(nil)
21   - assert_nothing_raised do
22   - assert_equal '', a.to_html
23   - end
  18 + should 'display profile info' do
  19 + e = Enterprise.create!(:name => 'my test enterprise', :identifier => 'mytestenterprise', :contact_email => 'ent@noosfero.foo.bar', :contact_phone => '5555 5555')
  20 + a = EnterpriseHomepage.new(:name => 'article homepage')
  21 + e.articles << a
  22 + result = a.to_html
  23 + assert_match /ent@noosfero.foo.bar/, result
  24 + assert_match /5555 5555/, result
24 25 end
25 26  
26 27 end
... ...