Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Bring back UI for removing members from teams
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Jul 20, 2016
1 parent 4e36bef commit caedf84
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gratipay/models/team/mixins/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_memberships(self, current_participant=None):
member['balance'] = take['balance']
member['percentage'] = take['percentage']

member['removal_allowed'] = current_participant == self
member['removal_allowed'] = current_participant.username == self.owner
member['editing_allowed'] = False
member['is_current_user'] = False
if current_participant is not None:
Expand Down
6 changes: 3 additions & 3 deletions js/gratipay/team.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Gratipay.team = (function() {
];

if (member.removal_allowed)
return ['span', {'class': 'remove', 'data-username': member.username}, take];
return ['span', {'class': 'remove', 'data-id': member.participant_id}, take];

return take;
}
Expand Down Expand Up @@ -133,8 +133,8 @@ Gratipay.team = (function() {
function remove(e) {
e.preventDefault();
e.stopPropagation();
var membername = $(e.target).attr('data-username');
setTake(membername, '0.00');
var participantId = $(e.target).data('id');
setTake(participantId, '0.00');
return false;
}

Expand Down
19 changes: 19 additions & 0 deletions tests/ttw/test_team_distributing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@ def test_owner_can_add_a_member(self):
self.css('#lookup-container button').first.click()
assert [a.text for a in self.css('table#team a')] == ['alice']


def test_owner_can_remove_a_member(self):
enterprise = self.make_team(available=500)
alice = self.make_participant( 'alice'
, claimed_time='now'
, email_address='[email protected]'
, verified_in='TT'
)
enterprise.add_member(alice, P('picard'))

self.sign_in('picard')
self.visit('/TheEnterprise/distributing/')
self.css('table#team span.remove').first.click()
time.sleep(0.1)
self.get_alert().accept()
time.sleep(0.2)
assert enterprise.get_memberships() == []


def test_totals_are_as_expected(self):
enterprise = self.make_team(available=500)
alice = self.make_participant( 'alice'
Expand Down

0 comments on commit caedf84

Please sign in to comment.