Commit 90db0fd70b5a0a2613cd00ffea234bf09c534648

Authored by Braulio Bhavamitra
2 parents cff14440 f9b414da

Merge branch 'confirm-leave' into noosfero

app/views/blocks/profile_info_actions/_join_leave_community.html.erb
1 <div class='join-leave-button require-login-popup'> 1 <div class='join-leave-button require-login-popup'>
2 <% if logged_in? %> 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;') %> 3 + <% if profile.already_request_membership? user %>
  4 + <%= _('Your membership is waiting for approval') %>
12 <% else %> 5 <% 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;') %> 6 + <% if user.in? profile.members %>
  7 + <%= button :delete, content_tag('span', _('Leave community')), profile.leave_url,
  8 + class: 'leave-community',
  9 + style: 'position: relative;' %>
  10 + <%= button :add, content_tag('span', _('Join this community')), profile.join_url,
  11 + class: 'join-community',
  12 + style: 'position: relative; display: none;' %>
  13 + <% else %>
  14 + <%= button :add, _('Join this community'), profile.join_url %>
22 <% end %> 15 <% end %>
23 <% end %> 16 <% end %>
24 <% else %> 17 <% else %>
25 - <%= button(:add, _('Join'), profile.join_not_logged_url, :title => _('Join this community')) %> 18 + <%= button :add, _('Join this community'), profile.join_not_logged_url %>
26 <% end %> 19 <% end %>
27 </div> 20 </div>
  21 +
  22 +<%= javascript_tag do %>
  23 + noosfero.add_and_join.locales.leaveConfirmation = <%= (_("Please confirm to leave the community '%{name}'") % {name: profile.name}).to_json %>
  24 +<% end %>
  25 +
features/accept_member.feature
@@ -14,6 +14,16 @@ Feature: accept member @@ -14,6 +14,16 @@ Feature: accept member
14 And the community "My Community" is closed 14 And the community "My Community" is closed
15 And "Mario Souto" is admin of "My Community" 15 And "Mario Souto" is admin of "My Community"
16 16
  17 + Scenario: a user should see its merbership is pending
  18 + Given I am logged in as "mario"
  19 + And the following communities
  20 + | owner | identifier | name | closed |
  21 + | marie | private-community | Private Community | true |
  22 + And I go to private-community's homepage
  23 + When I follow "Join this community"
  24 + And I go to private-community's homepage
  25 + Then I should see "Your membership is waiting for approval"
  26 +
17 @selenium 27 @selenium
18 Scenario: approve a task to accept a member as admin in a closed community 28 Scenario: approve a task to accept a member as admin in a closed community
19 Given "Marie Curie" asked to join "My Community" 29 Given "Marie Curie" asked to join "My Community"
features/members_block.feature
@@ -9,8 +9,8 @@ Feature: @@ -9,8 +9,8 @@ Feature:
9 | joaosilva | Joao Silva | 9 | joaosilva | Joao Silva |
10 | mariasilva | Maria Silva | 10 | mariasilva | Maria Silva |
11 And the following communities 11 And the following communities
12 - | owner | identifier | name |  
13 - | joaosilva | sample-community | Sample Community | 12 + | owner | identifier | name |
  13 + | joaosilva | sample-community | Sample Community |
14 And the following blocks 14 And the following blocks
15 | owner | type | 15 | owner | type |
16 | sample-community | MembersBlock | 16 | sample-community | MembersBlock |
@@ -24,7 +24,7 @@ Feature: @@ -24,7 +24,7 @@ Feature:
24 Scenario: a user can join in a community by members block's button 24 Scenario: a user can join in a community by members block's button
25 Given I am logged in as "mariasilva" 25 Given I am logged in as "mariasilva"
26 And I go to sample-community's homepage 26 And I go to sample-community's homepage
27 - When I follow "Join" within ".members-block" 27 + When I follow "Join this community" within ".members-block"
28 And I go to mariasilva's control panel 28 And I go to mariasilva's control panel
29 And I follow "Manage my groups" 29 And I follow "Manage my groups"
30 Then I should see "Sample Community" 30 Then I should see "Sample Community"
@@ -41,7 +41,7 @@ Feature: @@ -41,7 +41,7 @@ Feature:
41 Scenario: a not logged in user can log in by members block's button 41 Scenario: a not logged in user can log in by members block's button
42 Given I am not logged in 42 Given I am not logged in
43 When I go to sample-community's homepage 43 When I go to sample-community's homepage
44 - And I follow "Join" within ".members-block" 44 + And I follow "Join this community" within ".members-block"
45 Then I should see "Username / Email" 45 Then I should see "Username / Email"
46 46
47 Scenario: the join-leave button do not appear if the checkbox show-join-leave-button is not checked 47 Scenario: the join-leave button do not appear if the checkbox show-join-leave-button is not checked
@@ -51,5 +51,5 @@ Feature: @@ -51,5 +51,5 @@ Feature:
51 And I uncheck "Show join leave button" 51 And I uncheck "Show join leave button"
52 And I press "Save" 52 And I press "Save"
53 When I go to sample-community's homepage 53 When I go to sample-community's homepage
54 - Then I should not see "Join" within ".members-block" 54 + Then I should not see "Join this community" within ".members-block"
55 And I should not see "Leave community" within ".members-block" 55 And I should not see "Leave community" within ".members-block"
public/javascripts/add-and-join.js
  1 +noosfero.add_and_join = {
  2 + locales: {
  3 + leaveConfirmation: '',
  4 + },
  5 +};
  6 +
1 jQuery(function($) { 7 jQuery(function($) {
2 8
3 $(".add-friend").live('click', function(){ 9 $(".add-friend").live('click', function(){
@@ -29,6 +35,8 @@ jQuery(function($) { @@ -29,6 +35,8 @@ jQuery(function($) {
29 }) 35 })
30 36
31 $(".leave-community").live('click', function(){ 37 $(".leave-community").live('click', function(){
  38 + if (!confirm(noosfero.add_and_join.locales.leaveConfirmation))
  39 + return false;
32 clicked = $(this); 40 clicked = $(this);
33 url = clicked.attr("href"); 41 url = clicked.attr("href");
34 loading_for_button(this); 42 loading_for_button(this);