Commit 6345edbfc629e8f56c21f8a9d325d02219f0fb45

Authored by Antonio Terceiro
2 parents 3348eada 4258c807

Merge branch 'profile_description_block' into 'master'

Profile description block

this plugin adds a block that displays the description field of the profile.

See merge request !464
plugins/profile_description_block/lib/profile_description_block.rb 0 → 100644
... ... @@ -0,0 +1,41 @@
  1 +class ProfileDescriptionBlock < Block
  2 + settings_items :show_name, :type => :boolean,
  3 + :default => false
  4 +
  5 + attr_accessor :show_name
  6 +
  7 + def self.description
  8 + _('Profile Description')
  9 + end
  10 +
  11 + def help
  12 + _('this block displays the description field of the profile')
  13 + end
  14 +
  15 + def default_title
  16 + _('PROFILE DESCRIPTION')
  17 + end
  18 +
  19 + def content(args={})
  20 + description = if self.owner.description.blank?
  21 + "Description field is empty or
  22 + not enabled on enviroment"
  23 + else
  24 + self.owner.description
  25 + end
  26 + block = self
  27 + s = show_name
  28 + proc do
  29 + render(
  30 + :file => 'blocks/profile_description',
  31 + :locals => { :block => block, :show_name => s ,
  32 + :description => description}
  33 + )
  34 + end
  35 + end
  36 +
  37 + def cacheable?
  38 + false
  39 + end
  40 +
  41 +end
... ...
plugins/profile_description_block/lib/profile_description_block_plugin.rb 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +class ProfileDescriptionBlockPlugin < Noosfero::Plugin
  2 +
  3 + def self.plugin_name
  4 + # FIXME
  5 + "Profile Description Block"
  6 + end
  7 +
  8 + def self.extra_blocks
  9 + {
  10 + ProfileDescriptionBlock => { :type => [Community, Person] }
  11 + }
  12 + end
  13 +
  14 +
  15 + def self.plugin_description
  16 + # FIXME
  17 + _("A plugin that adds a block that show the profile description")
  18 + end
  19 +
  20 + def stylesheet?
  21 + true
  22 + end
  23 +
  24 +end
... ...
plugins/profile_description_block/public/style.css 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +#content .box-1 .profile-description-block {
  2 + display: table;
  3 + width: 100%;
  4 +}
  5 +
  6 +#content .profile-description-block-title {
  7 + font-family: arial;
  8 + font-size: 15px;
  9 + text-align: left;
  10 +}
... ...
plugins/profile_description_block/test/unit/profile_description_block_test.rb 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +require File.expand_path(File.dirname(__FILE__) + "/../../../../test/test_helper")
  2 +
  3 +class ProfileDescriptionBlockTest < ActiveSupport::TestCase
  4 + def setup
  5 + e = Environment.default
  6 + e.enabled_plugins = ['ProfileDescriptionPlugin']
  7 + @person = create_user('test_user').person
  8 + @profile = Profile.create!(:identifier => '1236',
  9 + :name => 'blabla',
  10 + :description => "")
  11 + end
  12 +
  13 + should 'describe itself' do
  14 + assert_not_equal Block.description, ProfileDescriptionBlock.description
  15 + end
  16 +
  17 + should "show profile description inside block" do
  18 + new_block = ProfileDescriptionBlock.create!
  19 + @profile.boxes.first.blocks << new_block
  20 + block_menssage = "Description field are empty"
  21 + assert (instance_eval(&Block.last.content).include?(block_menssage)),
  22 + "description block doesn't show not found description message"
  23 + description = "This is an test"
  24 + @profile.update_attribute("description", description)
  25 + @profile.save!
  26 + assert (instance_eval(&Block.last.content).include?(description)),
  27 + "Description block doesn't show profile description"
  28 + end
  29 +end
... ...
plugins/profile_description_block/views/blocks/profile_description.html.erb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +<div class = 'profile-description-block'>
  2 +<div class = "block-title">
  3 + <%= block.title %>
  4 +</div>
  5 +<div class = "profile-description-block-title">
  6 + <%= description %>
  7 +</div>
  8 +</div>
... ...
test/unit/article_block_test.rb
1 1 require_relative "../test_helper"
2 2  
3 3 class ArticleBlockTest < ActiveSupport::TestCase
4   -
5 4 include ApplicationHelper
6 5  
7 6 should 'describe itself' do
... ...