[Git][noosfero/noosfero][master] 2 commits: community: confirm leave
Bráulio Bhavamitra
gitlab at gitlab.com
Mon Aug 10 21:11:27 BRT 2015
Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero
Commits:
f9b414da by Braulio Bhavamitra at 2015-08-10T20:41:16Z
community: confirm leave
- - - - -
90db0fd7 by Braulio Bhavamitra at 2015-08-10T21:10:15Z
Merge branch 'confirm-leave' into noosfero
- - - - -
4 changed files:
- app/views/blocks/profile_info_actions/_join_leave_community.html.erb
- features/accept_member.feature
- features/members_block.feature
- public/javascripts/add-and-join.js
Changes:
=====================================
app/views/blocks/profile_info_actions/_join_leave_community.html.erb
=====================================
--- a/app/views/blocks/profile_info_actions/_join_leave_community.html.erb
+++ b/app/views/blocks/profile_info_actions/_join_leave_community.html.erb
@@ -1,27 +1,25 @@
<div class='join-leave-button require-login-popup'>
<% if logged_in? %>
- <% if profile.members.include?(user) %>
- <%= button(:delete, content_tag('span', _('Leave community')), profile.leave_url,
- :class => 'leave-community',
- :title => _("Leave community"),
- :style => 'position: relative;') %>
- <%= button(:add, content_tag('span', _('Join')), profile.join_url,
- :class => 'join-community',
- :title => _("Join community"),
- :style => 'position: relative; display: none;') %>
+ <% if profile.already_request_membership? user %>
+ <%= _('Your membership is waiting for approval') %>
<% else %>
- <% unless profile.already_request_membership?(user) %>
- <%= button(:delete, content_tag('span', _('Leave community')), profile.leave_url,
- :class => 'leave-community',
- :title => _("Leave community"),
- :style => 'position: relative; display: none;') %>
- <%= button(:add, content_tag('span', _('Join')), profile.join_url,
- :class => 'join-community',
- :title => _("Join community"),
- :style => 'position: relative;') %>
+ <% if user.in? profile.members %>
+ <%= button :delete, content_tag('span', _('Leave community')), profile.leave_url,
+ class: 'leave-community',
+ style: 'position: relative;' %>
+ <%= button :add, content_tag('span', _('Join this community')), profile.join_url,
+ class: 'join-community',
+ style: 'position: relative; display: none;' %>
+ <% else %>
+ <%= button :add, _('Join this community'), profile.join_url %>
<% end %>
<% end %>
<% else %>
- <%= button(:add, _('Join'), profile.join_not_logged_url, :title => _('Join this community')) %>
+ <%= button :add, _('Join this community'), profile.join_not_logged_url %>
<% end %>
</div>
+
+<%= javascript_tag do %>
+ noosfero.add_and_join.locales.leaveConfirmation = <%= (_("Please confirm to leave the community '%{name}'") % {name: profile.name}).to_json %>
+<% end %>
+
=====================================
features/accept_member.feature
=====================================
--- a/features/accept_member.feature
+++ b/features/accept_member.feature
@@ -14,6 +14,16 @@ Feature: accept member
And the community "My Community" is closed
And "Mario Souto" is admin of "My Community"
+ Scenario: a user should see its merbership is pending
+ Given I am logged in as "mario"
+ And the following communities
+ | owner | identifier | name | closed |
+ | marie | private-community | Private Community | true |
+ And I go to private-community's homepage
+ When I follow "Join this community"
+ And I go to private-community's homepage
+ Then I should see "Your membership is waiting for approval"
+
@selenium
Scenario: approve a task to accept a member as admin in a closed community
Given "Marie Curie" asked to join "My Community"
=====================================
features/members_block.feature
=====================================
--- a/features/members_block.feature
+++ b/features/members_block.feature
@@ -9,8 +9,8 @@ Feature:
| joaosilva | Joao Silva |
| mariasilva | Maria Silva |
And the following communities
- | owner | identifier | name |
- | joaosilva | sample-community | Sample Community |
+ | owner | identifier | name |
+ | joaosilva | sample-community | Sample Community |
And the following blocks
| owner | type |
| sample-community | MembersBlock |
@@ -24,7 +24,7 @@ Feature:
Scenario: a user can join in a community by members block's button
Given I am logged in as "mariasilva"
And I go to sample-community's homepage
- When I follow "Join" within ".members-block"
+ When I follow "Join this community" within ".members-block"
And I go to mariasilva's control panel
And I follow "Manage my groups"
Then I should see "Sample Community"
@@ -41,7 +41,7 @@ Feature:
Scenario: a not logged in user can log in by members block's button
Given I am not logged in
When I go to sample-community's homepage
- And I follow "Join" within ".members-block"
+ And I follow "Join this community" within ".members-block"
Then I should see "Username / Email"
Scenario: the join-leave button do not appear if the checkbox show-join-leave-button is not checked
@@ -51,5 +51,5 @@ Feature:
And I uncheck "Show join leave button"
And I press "Save"
When I go to sample-community's homepage
- Then I should not see "Join" within ".members-block"
+ Then I should not see "Join this community" within ".members-block"
And I should not see "Leave community" within ".members-block"
=====================================
public/javascripts/add-and-join.js
=====================================
--- a/public/javascripts/add-and-join.js
+++ b/public/javascripts/add-and-join.js
@@ -1,3 +1,9 @@
+noosfero.add_and_join = {
+ locales: {
+ leaveConfirmation: '',
+ },
+};
+
jQuery(function($) {
$(".add-friend").live('click', function(){
@@ -29,6 +35,8 @@ jQuery(function($) {
})
$(".leave-community").live('click', function(){
+ if (!confirm(noosfero.add_and_join.locales.leaveConfirmation))
+ return false;
clicked = $(this);
url = clicked.attr("href");
loading_for_button(this);
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/cff1444052b81d7281a6e6a4254d05510e5a7201...90db0fd70b5a0a2613cd00ffea234bf09c534648
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150811/40a2c524/attachment-0001.html>
More information about the Noosfero-dev
mailing list