diff --git a/app/helpers/enterprise_homepage_helper.rb b/app/helpers/enterprise_homepage_helper.rb
new file mode 100644
index 0000000..6a6b799
--- /dev/null
+++ b/app/helpers/enterprise_homepage_helper.rb
@@ -0,0 +1,35 @@
+module EnterpriseHomepageHelper
+
+ def display_profile_info(profile)
+ data = ''
+ unless profile.contact_person.blank?
+ data << content_tag('strong', _('Contact person: ')) + profile.contact_person + '
'
+ end
+ unless profile.contact_email.blank?
+ data << content_tag('strong', _('E-Mail: ')) + profile.contact_email + '
'
+ end
+ unless profile.contact_phone.blank?
+ data << content_tag('strong', _('Phone(s): ')) + profile.contact_phone + '
'
+ end
+ unless profile.region.nil?
+ data << content_tag('strong', _('Location: ')) + profile.region.name + '
'
+ end
+ unless profile.address.blank?
+ data << content_tag('strong', _('Address: ')) + profile.address + '
'
+ end
+ unless profile.legal_form.blank?
+ data << content_tag('strong', _('Legal form: ')) + profile.legal_form + '
'
+ end
+ unless profile.foundation_year.blank?
+ data << content_tag('strong', _('Foundation year: ')) + profile.foundation_year + '
'
+ end
+ unless profile.economic_activity.blank?
+ data << content_tag('strong', _('Economic activity: ')) + profile.economic_activity + '
'
+ end
+ if profile.respond_to?(:distance) and !profile.distance.nil?
+ data << content_tag('strong', _('Distance: ')) + "%.2f%" % profile.distance + '
'
+ end
+ content_tag('div', data, :class => 'profile-info')
+ end
+
+end
diff --git a/app/models/enterprise_homepage.rb b/app/models/enterprise_homepage.rb
index 02becd7..b4e2389 100644
--- a/app/models/enterprise_homepage.rb
+++ b/app/models/enterprise_homepage.rb
@@ -8,8 +8,14 @@ class EnterpriseHomepage < Article
_('Display the summary of profile.')
end
+ # FIXME isn't this too much including just to be able to generate some HTML?
+ include ActionView::Helpers::TagHelper
+ include ActionView::Helpers::UrlHelper
+ include ActionController::UrlWriter
+ include ActionView::Helpers::AssetTagHelper
+ include EnterpriseHomepageHelper
def to_html
- body || ''
+ display_profile_info(self.profile) + content_tag('div', self.body || '')
end
end
diff --git a/public/designs/themes/ecosol/stylesheets/controller_content_viewer.css b/public/designs/themes/ecosol/stylesheets/controller_content_viewer.css
new file mode 100644
index 0000000..d49a3fd
--- /dev/null
+++ b/public/designs/themes/ecosol/stylesheets/controller_content_viewer.css
@@ -0,0 +1,8 @@
+/************* enterprise homepage style *****************/
+
+.profile-info {
+ border: none;
+ background: #B8CFE7;
+ -moz-border-radius: 15px;
+ padding: 10px;
+}
diff --git a/public/stylesheets/controller_cms.css b/public/stylesheets/controller_cms.css
index 21194f2..de68c30 100644
--- a/public/stylesheets/controller_cms.css
+++ b/public/stylesheets/controller_cms.css
@@ -122,4 +122,3 @@ div.file-manager-button a:hover {
.file-manager-small .file-manager-controls * {
text-align: right;
}
-
diff --git a/public/stylesheets/controller_content_viewer.css b/public/stylesheets/controller_content_viewer.css
new file mode 100644
index 0000000..dd29a77
--- /dev/null
+++ b/public/stylesheets/controller_content_viewer.css
@@ -0,0 +1,2 @@
+/************* enterprise homepage style *****************/
+
diff --git a/test/unit/enterprise_homepage_test.rb b/test/unit/enterprise_homepage_test.rb
index 6340912..8008ec0 100644
--- a/test/unit/enterprise_homepage_test.rb
+++ b/test/unit/enterprise_homepage_test.rb
@@ -15,12 +15,13 @@ class EnterpriseHomepageTest < Test::Unit::TestCase
assert_kind_of String, EnterpriseHomepage.description
end
- should 'accept empty body' do
- a = EnterpriseHomepage.new
- a.expects(:body).returns(nil)
- assert_nothing_raised do
- assert_equal '', a.to_html
- end
+ should 'display profile info' do
+ e = Enterprise.create!(:name => 'my test enterprise', :identifier => 'mytestenterprise', :contact_email => 'ent@noosfero.foo.bar', :contact_phone => '5555 5555')
+ a = EnterpriseHomepage.new(:name => 'article homepage')
+ e.articles << a
+ result = a.to_html
+ assert_match /ent@noosfero.foo.bar/, result
+ assert_match /5555 5555/, result
end
end
--
libgit2 0.21.2