Commit 6345edbfc629e8f56c21f8a9d325d02219f0fb45
Exists in
master
and in
29 other branches
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
Showing
6 changed files
with
112 additions
and
1 deletions
Show diff stats
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/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