Commit 0a187954dba951cd2d9288f7974131f106416e6c
Exists in
master
and in
29 other branches
Merge branch 'master' of https://gitlab.com/noosfero/noosfero
Showing
11 changed files
with
152 additions
and
48 deletions
Show diff stats
app/helpers/box_organizer_helper.rb
@@ -4,4 +4,10 @@ module BoxOrganizerHelper | @@ -4,4 +4,10 @@ module BoxOrganizerHelper | ||
4 | render :partial => 'icon_selector', :locals => { :icon => icon } | 4 | render :partial => 'icon_selector', :locals => { :icon => icon } |
5 | end | 5 | end |
6 | 6 | ||
7 | -end | 7 | + def extra_option_checkbox(option) |
8 | + if [:human_name, :name, :value, :checked, :options].all? {|k| option.key? k} | ||
9 | + labelled_check_box(option[:human_name], option[:name], option[:value], option[:checked], option[:options]) | ||
10 | + end | ||
11 | + end | ||
12 | + | ||
13 | +end | ||
8 | \ No newline at end of file | 14 | \ No newline at end of file |
app/models/members_block.rb
1 | class MembersBlock < ProfileListBlock | 1 | class MembersBlock < ProfileListBlock |
2 | + settings_items :show_join_leave_button, :type => :boolean, :default => false | ||
2 | 3 | ||
3 | def self.description | 4 | def self.description |
4 | _('Members') | 5 | _('Members') |
@@ -14,8 +15,10 @@ class MembersBlock < ProfileListBlock | @@ -14,8 +15,10 @@ class MembersBlock < ProfileListBlock | ||
14 | 15 | ||
15 | def footer | 16 | def footer |
16 | profile = self.owner | 17 | profile = self.owner |
18 | + s = show_join_leave_button | ||
19 | + | ||
17 | lambda do | 20 | lambda do |
18 | - link_to _('View all'), :profile => profile.identifier, :controller => 'profile', :action => 'members' | 21 | + render :file => 'blocks/members', :locals => { :profile => profile, :show_join_leave_button => s} |
19 | end | 22 | end |
20 | end | 23 | end |
21 | 24 | ||
@@ -23,4 +26,14 @@ class MembersBlock < ProfileListBlock | @@ -23,4 +26,14 @@ class MembersBlock < ProfileListBlock | ||
23 | owner.members | 26 | owner.members |
24 | end | 27 | end |
25 | 28 | ||
29 | + def extra_option | ||
30 | + data = { | ||
31 | + :human_name => _("Show join leave button"), | ||
32 | + :name => 'block[show_join_leave_button]', | ||
33 | + :value => true, | ||
34 | + :checked => show_join_leave_button, | ||
35 | + :options => {} | ||
36 | + } | ||
37 | + end | ||
38 | + | ||
26 | end | 39 | end |
app/models/profile_list_block.rb
@@ -62,4 +62,8 @@ class ProfileListBlock < Block | @@ -62,4 +62,8 @@ class ProfileListBlock < Block | ||
62 | title.gsub('{#}', profile_count.to_s) | 62 | title.gsub('{#}', profile_count.to_s) |
63 | end | 63 | end |
64 | 64 | ||
65 | + # override in subclasses! See MembersBlock for example | ||
66 | + def extra_option | ||
67 | + {} | ||
68 | + end | ||
65 | end | 69 | end |
app/views/blocks/profile_info_actions/_join_leave_community.rhtml
0 → 100644
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | +<div class='join-leave-button'> | ||
2 | + <% if logged_in? %> | ||
3 | + <% if profile.members.include?(user) %> | ||
4 | + <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, | ||
5 | + :class => 'leave-community', | ||
6 | + :title => _("Leave community"), | ||
7 | + :style => 'position: relative;') %> | ||
8 | + <%= button(:add, content_tag('span', __('Join')), profile.join_url, | ||
9 | + :class => 'join-community', | ||
10 | + :title => _("Join community"), | ||
11 | + :style => 'position: relative; display: none;') %> | ||
12 | + <% else %> | ||
13 | + <% unless profile.already_request_membership?(user) %> | ||
14 | + <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, | ||
15 | + :class => 'leave-community', | ||
16 | + :title => _("Leave community"), | ||
17 | + :style => 'position: relative; display: none;') %> | ||
18 | + <%= button(:add, content_tag('span', __('Join')), profile.join_url, | ||
19 | + :class => 'join-community', | ||
20 | + :title => _("Join community"), | ||
21 | + :style => 'position: relative;') %> | ||
22 | + <% end %> | ||
23 | + <% end %> | ||
24 | + <% else %> | ||
25 | + <%= link_to content_tag('span', _('Join')), profile.join_not_logged_url, | ||
26 | + :class => 'button with-text icon-add', | ||
27 | + :title => _('Join this community') %> | ||
28 | + <% end %> | ||
29 | +</div> |
app/views/blocks/profile_info_actions/community.rhtml
1 | <ul> | 1 | <ul> |
2 | + <li> | ||
3 | + <%= render "blocks/profile_info_actions/join_leave_community" %> | ||
4 | + </li> | ||
2 | <% if logged_in? %> | 5 | <% if logged_in? %> |
3 | - <% if profile.members.include?(user) %> | ||
4 | - <li> | ||
5 | - <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, | ||
6 | - :class => 'leave-community', | ||
7 | - :title => _("Leave community"), | ||
8 | - :style => 'position: relative;') %> | ||
9 | - <%= button(:add, content_tag('span', __('Join')), profile.join_url, | ||
10 | - :class => 'join-community', | ||
11 | - :title => _("Join community"), | ||
12 | - :style => 'position: relative; display: none;') %> | ||
13 | - </li> | ||
14 | - <% else %> | ||
15 | - <% unless profile.already_request_membership?(user) %> | ||
16 | - <li> | ||
17 | - <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, | ||
18 | - :class => 'leave-community', | ||
19 | - :title => _("Leave community"), | ||
20 | - :style => 'position: relative; display: none;') %> | ||
21 | - <%= button(:add, content_tag('span', __('Join')), profile.join_url, | ||
22 | - :class => 'join-community', | ||
23 | - :title => _("Join community"), | ||
24 | - :style => 'position: relative;') %> | ||
25 | - </li> | ||
26 | - <% end %> | ||
27 | - <% end %> | ||
28 | - | ||
29 | <% if profile.enable_contact? %> | 6 | <% if profile.enable_contact? %> |
30 | <li> | 7 | <li> |
31 | <%= link_to content_tag('span', _('Send an e-mail')), | 8 | <%= link_to content_tag('span', _('Send an e-mail')), |
@@ -39,11 +16,5 @@ | @@ -39,11 +16,5 @@ | ||
39 | <li><%= report_abuse(profile, :button) %></li> | 16 | <li><%= report_abuse(profile, :button) %></li> |
40 | 17 | ||
41 | <%= render_environment_features(:profile_actions) %> | 18 | <%= render_environment_features(:profile_actions) %> |
42 | - <% else %> | ||
43 | - <li> | ||
44 | - <%= link_to content_tag('span', _('Join')), profile.join_not_logged_url, | ||
45 | - :class => 'button with-text icon-add', | ||
46 | - :title => _('Join this community') %> | ||
47 | - </li> | ||
48 | <% end %> | 19 | <% end %> |
49 | -</ul> | 20 | -</ul> |
21 | +</ul> | ||
50 | \ No newline at end of file | 22 | \ No newline at end of file |
app/views/box_organizer/_profile_list_block.rhtml
@@ -2,5 +2,8 @@ | @@ -2,5 +2,8 @@ | ||
2 | <%= labelled_form_field _('Limit of items'), text_field(:block, :limit, :size => 3) %> | 2 | <%= labelled_form_field _('Limit of items'), text_field(:block, :limit, :size => 3) %> |
3 | <%= check_box(:block, :prioritize_profiles_with_image) %> | 3 | <%= check_box(:block, :prioritize_profiles_with_image) %> |
4 | <label for="block_prioritize_profiles_with_image"><%= _('Prioritize profiles with image') %></label> | 4 | <label for="block_prioritize_profiles_with_image"><%= _('Prioritize profiles with image') %></label> |
5 | -</div> | ||
6 | 5 | ||
6 | + <div> | ||
7 | + <%= extra_option_checkbox(@block.extra_option) %> | ||
8 | + </div> | ||
9 | +</div> | ||
7 | \ No newline at end of file | 10 | \ No newline at end of file |
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +Feature: | ||
2 | + In order to enter in a community | ||
3 | + As a logged user | ||
4 | + I want to enter in a community by 'join leave' button in members block | ||
5 | + | ||
6 | + Background: | ||
7 | + Given the following users | ||
8 | + | login | name | | ||
9 | + | joaosilva | Joao Silva | | ||
10 | + | mariasilva | Maria Silva | | ||
11 | + And the following communities | ||
12 | + | owner | identifier | name | | ||
13 | + | joaosilva | sample-community | Sample Community | | ||
14 | + And the following blocks | ||
15 | + | owner | type | | ||
16 | + | sample-community | MembersBlock | | ||
17 | + And I am logged in as "joaosilva" | ||
18 | + And I go to sample-community's control panel | ||
19 | + And I follow "Edit sideboxes" | ||
20 | + And I follow "Edit" within ".members-block" | ||
21 | + And I check "Show join leave button" | ||
22 | + And I press "Save" | ||
23 | + | ||
24 | + Scenario: a user can join in a community by members block's button | ||
25 | + Given I am logged in as "mariasilva" | ||
26 | + And I go to sample-community's homepage | ||
27 | + When I follow "Join" within ".members-block" | ||
28 | + And I go to mariasilva's control panel | ||
29 | + And I follow "Manage my groups" | ||
30 | + Then I should see "Sample Community" | ||
31 | + | ||
32 | + Scenario: a user can leave a community by members block's button | ||
33 | + Given "Maria Silva" is a member of "Sample Community" | ||
34 | + And I am logged in as "mariasilva" | ||
35 | + When I go to sample-community's homepage | ||
36 | + And I follow "Leave community" within ".members-block" | ||
37 | + And I go to mariasilva's control panel | ||
38 | + And I follow "Manage my groups" | ||
39 | + Then I should not see "Sample Community" | ||
40 | + | ||
41 | + Scenario: a not logged in user can log in by members block's button | ||
42 | + Given I am not logged in | ||
43 | + When I go to sample-community's homepage | ||
44 | + And I follow "Join" within ".members-block" | ||
45 | + Then I should see "Username / Email" | ||
46 | + | ||
47 | + Scenario: the join-leave button do not appear if the checkbox show-join-leave-button is not checked | ||
48 | + And I go to sample-community's control panel | ||
49 | + And I follow "Edit sideboxes" | ||
50 | + And I follow "Edit" within ".members-block" | ||
51 | + And I uncheck "Show join leave button" | ||
52 | + And I press "Save" | ||
53 | + When I go to sample-community's homepage | ||
54 | + Then I should not see "Join" within ".members-block" | ||
55 | + And I should not see "Leave community" within ".members-block" |
public/designs/themes/base/style.css
@@ -516,9 +516,31 @@ div#notice { | @@ -516,9 +516,31 @@ div#notice { | ||
516 | color: #000; | 516 | color: #000; |
517 | text-decoration: none; | 517 | text-decoration: none; |
518 | padding-right: 15px; | 518 | padding-right: 15px; |
519 | +} | ||
520 | +#content .tags-block .block-footer-content a, | ||
521 | +#content .people-block .block-footer-content a, | ||
522 | +#content .profile-list-block .block-footer-content a, | ||
523 | +#content .enterprises-block .block-footer-content a, | ||
524 | +#content .communities-block .block-footer-content a, | ||
525 | +#content .friends-block .block-footer-content a { | ||
519 | background: url(imgs/arrow-right-p.png) 100% 50% no-repeat; | 526 | background: url(imgs/arrow-right-p.png) 100% 50% no-repeat; |
520 | } | 527 | } |
521 | 528 | ||
529 | +#content .members-block .block-footer-content .join-leave-button a { | ||
530 | + position: relative; | ||
531 | + background-color: #EEE; | ||
532 | + border: 1px solid #CCC; | ||
533 | + color: #555; | ||
534 | + padding-right: inherit; | ||
535 | +} | ||
536 | + | ||
537 | +#content .members-block .block-footer-content .join-leave-button a:hover { | ||
538 | + color: #FFF; | ||
539 | + background-color: #555; | ||
540 | + border: 1px solid #2e3436; | ||
541 | + text-decoration: none; | ||
542 | +} | ||
543 | + | ||
522 | #content .profile-list-block .block-title { | 544 | #content .profile-list-block .block-title { |
523 | text-align: left; | 545 | text-align: left; |
524 | } | 546 | } |
public/javascripts/add-and-join.js
@@ -12,7 +12,7 @@ jQuery(function($) { | @@ -12,7 +12,7 @@ jQuery(function($) { | ||
12 | }) | 12 | }) |
13 | 13 | ||
14 | $(".join-community").live('click', function(){ | 14 | $(".join-community").live('click', function(){ |
15 | - clicked = $(this) | 15 | + clicked = $(".join-community"); |
16 | url = clicked.attr("href"); | 16 | url = clicked.attr("href"); |
17 | loading_for_button(this); | 17 | loading_for_button(this); |
18 | $.post(url, function(data){ | 18 | $.post(url, function(data){ |
@@ -29,7 +29,7 @@ jQuery(function($) { | @@ -29,7 +29,7 @@ jQuery(function($) { | ||
29 | }) | 29 | }) |
30 | 30 | ||
31 | $(".leave-community").live('click', function(){ | 31 | $(".leave-community").live('click', function(){ |
32 | - clicked = $(this) | 32 | + clicked = $(".leave-community"); |
33 | url = clicked.attr("href"); | 33 | url = clicked.attr("href"); |
34 | loading_for_button(this); | 34 | loading_for_button(this); |
35 | $.post(url, function(data){ | 35 | $.post(url, function(data){ |
test/unit/members_block_test.rb
@@ -14,16 +14,13 @@ class MembersBlockTest < ActiveSupport::TestCase | @@ -14,16 +14,13 @@ class MembersBlockTest < ActiveSupport::TestCase | ||
14 | assert_not_equal ProfileListBlock.new.default_title, MembersBlock.new.default_title | 14 | assert_not_equal ProfileListBlock.new.default_title, MembersBlock.new.default_title |
15 | end | 15 | end |
16 | 16 | ||
17 | - should 'link to "all members" page' do | ||
18 | - profile = create_user('mytestuser').person | ||
19 | - block = MembersBlock.new | ||
20 | - block.box = profile.boxes.first | ||
21 | - block.save! | ||
22 | - | ||
23 | - expects(:_).with('View all').returns('View all') | ||
24 | - expects(:link_to).with('View all' , :profile => 'mytestuser', :controller => 'profile', :action => 'members').returns('link-to-members') | 17 | + should 'display members file' do |
18 | + community = fast_create(Community) | ||
19 | + block = MembersBlock.create | ||
20 | + block.expects(:owner).returns(community) | ||
25 | 21 | ||
26 | - assert_equal 'link-to-members', instance_eval(&block.footer) | 22 | + self.expects(:render).with(:file => 'blocks/members', :locals => { :profile => community, :show_join_leave_button => false}).returns('file-with-members-list') |
23 | + assert_equal 'file-with-members-list', instance_eval(&block.footer) | ||
27 | end | 24 | end |
28 | 25 | ||
29 | should 'pick random members' do | 26 | should 'pick random members' do |
@@ -39,4 +36,3 @@ class MembersBlockTest < ActiveSupport::TestCase | @@ -39,4 +36,3 @@ class MembersBlockTest < ActiveSupport::TestCase | ||
39 | end | 36 | end |
40 | 37 | ||
41 | end | 38 | end |
42 | - |