Commit 3c41ae142f01a9aac524149665e223f629db14c0
Exists in
staging
and in
20 other branches
Merge branch 'field-of-interest' into 'master'
Ticket #85: The person_tags plugin now exposes a PersonTagsBlock The `person_tags` plugin exposes a block now, so people can show their interests in their profiles.  I also renamed `interest` to `tag` because it was in conflict with other Noosfero stuff. See merge request !963
Showing
12 changed files
with
85 additions
and
13 deletions
Show diff stats
plugins/person_tags/features/person_tags.feature
@@ -10,9 +10,9 @@ Background: | @@ -10,9 +10,9 @@ Background: | ||
10 | Scenario: add tags to person | 10 | Scenario: add tags to person |
11 | Given I am on joao's control panel | 11 | Given I am on joao's control panel |
12 | And I follow "Edit Profile" | 12 | And I follow "Edit Profile" |
13 | - When I fill in "profile_data_interest_list" with "linux,debian" | 13 | + When I fill in "profile_data_tag_list" with "linux,debian" |
14 | And I press "Save" | 14 | And I press "Save" |
15 | And I go to joao's control panel | 15 | And I go to joao's control panel |
16 | And I follow "Edit Profile" | 16 | And I follow "Edit Profile" |
17 | - Then the "profile_data_interest_list" field should contain "linux" | ||
18 | - And the "profile_data_interest_list" field should contain "debian" | 17 | + Then the "profile_data_tag_list" field should contain "linux" |
18 | + And the "profile_data_tag_list" field should contain "debian" |
plugins/person_tags/lib/ext/person.rb
plugins/person_tags/lib/person_tags_plugin.rb
@@ -19,4 +19,18 @@ class PersonTagsPlugin < Noosfero::Plugin | @@ -19,4 +19,18 @@ class PersonTagsPlugin < Noosfero::Plugin | ||
19 | def self.api_mount_points | 19 | def self.api_mount_points |
20 | [PersonTagsPlugin::API] | 20 | [PersonTagsPlugin::API] |
21 | end | 21 | end |
22 | + | ||
23 | + def self.extra_blocks | ||
24 | + { | ||
25 | + PersonTagsPlugin::InterestsBlock => { type: Person } | ||
26 | + } | ||
27 | + end | ||
28 | + | ||
29 | + def self.has_admin_url? | ||
30 | + false | ||
31 | + end | ||
32 | + | ||
33 | + def stylesheet? | ||
34 | + true | ||
35 | + end | ||
22 | end | 36 | end |
plugins/person_tags/lib/person_tags_plugin/api.rb
@@ -3,7 +3,7 @@ class PersonTagsPlugin::API < Grape::API | @@ -3,7 +3,7 @@ class PersonTagsPlugin::API < Grape::API | ||
3 | get ':id/tags' do | 3 | get ':id/tags' do |
4 | person = environment.people.visible.find_by(id: params[:id]) | 4 | person = environment.people.visible.find_by(id: params[:id]) |
5 | return not_found! if person.blank? | 5 | return not_found! if person.blank? |
6 | - present person.interest_list | 6 | + present person.tag_list |
7 | end | 7 | end |
8 | end | 8 | end |
9 | end | 9 | end |
plugins/person_tags/lib/person_tags_plugin/interests_block.rb
0 → 100644
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | +class PersonTagsPlugin::InterestsBlock < Block | ||
2 | + def view_title | ||
3 | + self.default_title | ||
4 | + end | ||
5 | + | ||
6 | + def tags | ||
7 | + owner.tag_list | ||
8 | + end | ||
9 | + | ||
10 | + def extra_option | ||
11 | + {} | ||
12 | + end | ||
13 | + | ||
14 | + def self.description | ||
15 | + _('Fields of Interest') | ||
16 | + end | ||
17 | + | ||
18 | + def help | ||
19 | + _('Things that this person is interested in') | ||
20 | + end | ||
21 | + | ||
22 | + def default_title | ||
23 | + _('Fields of Interest') | ||
24 | + end | ||
25 | + | ||
26 | + def self.expire_on | ||
27 | + { profile: [:profile] } | ||
28 | + end | ||
29 | +end |
plugins/person_tags/test/unit/api_test.rb
@@ -10,7 +10,7 @@ class APITest < ActiveSupport::TestCase | @@ -10,7 +10,7 @@ class APITest < ActiveSupport::TestCase | ||
10 | 10 | ||
11 | should 'return tags for a person' do | 11 | should 'return tags for a person' do |
12 | person = create_user('person').person | 12 | person = create_user('person').person |
13 | - person.interest_list.add('linux') | 13 | + person.tag_list.add('linux') |
14 | person.save! | 14 | person.save! |
15 | person.reload | 15 | person.reload |
16 | get "/api/v1/people/#{person.id}/tags?#{params.to_query}" | 16 | get "/api/v1/people/#{person.id}/tags?#{params.to_query}" |
plugins/person_tags/test/unit/person_tags_test.rb
@@ -7,10 +7,10 @@ class PersonTagsPluginTest < ActiveSupport::TestCase | @@ -7,10 +7,10 @@ class PersonTagsPluginTest < ActiveSupport::TestCase | ||
7 | @environment.enable_plugin(PersonTagsPlugin) | 7 | @environment.enable_plugin(PersonTagsPlugin) |
8 | end | 8 | end |
9 | 9 | ||
10 | - should 'have interests' do | 10 | + should 'have tags' do |
11 | person = create_user('person').person | 11 | person = create_user('person').person |
12 | - assert_equal [], person.interests | ||
13 | - person.interest_list.add('linux') | ||
14 | - assert_equal ['linux'], person.interest_list | 12 | + assert_equal [], person.tags |
13 | + person.tag_list.add('linux') | ||
14 | + assert_equal ['linux'], person.tag_list | ||
15 | end | 15 | end |
16 | end | 16 | end |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +<%= block_title(block.view_title, block.subtitle) %> | ||
2 | + | ||
3 | +<div class="person-tags-block"> | ||
4 | + <% unless block.tags.size == 0 %> | ||
5 | + <ul> | ||
6 | + <% block.tags.each do |tag| %> | ||
7 | + <li><%= tag %></li> | ||
8 | + <% end %> | ||
9 | + </ul> | ||
10 | + <% else %> | ||
11 | + <div class="person-tags-block-none"><%= c_('None') %></div> | ||
12 | + <% end %> | ||
13 | + <br style="clear:both" /> | ||
14 | +</div> |
plugins/person_tags/views/profile-editor-extras.html.erb
1 | <h2><%= _('Select your fields of interest') %></h2> | 1 | <h2><%= _('Select your fields of interest') %></h2> |
2 | -<%= text_field_tag('profile_data[interest_list]', context.profile.interest_list.join(','), size: 64) %> | 2 | +<%= text_field_tag('profile_data[tag_list]', context.profile.tag_list.join(','), size: 64) %> |
3 | <br /> | 3 | <br /> |
4 | <%= content_tag( 'small', _('Separate tags with commas') ) %> | 4 | <%= content_tag( 'small', _('Separate tags with commas') ) %> |
5 | 5 | ||
6 | <script> | 6 | <script> |
7 | - jQuery('#profile_data_interest_list').inputosaurus(); | 7 | + jQuery('#profile_data_tag_list').inputosaurus(); |
8 | </script> | 8 | </script> |