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

Commit

Permalink
Allow owners to add themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Sep 1, 2016
1 parent 241bc51 commit 0b88b4d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 8 additions & 3 deletions gratipay/models/team/mixins/takes.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ def vet(p):
vet(participant)
vet(recorder)

if recorder.username == self.owner:
if take not in (ZERO, PENNY):
owner_recording = recorder.username == self.owner
owner_taking = participant.username == self.owner
taker_recording = recorder == participant
adding_or_removing = take in (ZERO, PENNY)

if owner_recording:
if not adding_or_removing and not owner_taking:
raise NotAllowed("owner can only add and remove members, not otherwise set takes")
elif recorder != participant:
elif not taker_recording:
raise NotAllowed("can only set own take")

with self.db.get_cursor(cursor) as cursor:
Expand Down
6 changes: 2 additions & 4 deletions tests/py/test_billing_payday.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,11 @@ def test_pt_clips_to_balance_when_less_than_available(self):
assert P('zorro').balance == D(' 0.00')
assert P('picard').balance == D(' 0.00')

def test_pt_is_NOT_happy_to_deal_the_owner_in(self):
def test_pt_is_happy_to_deal_the_owner_in(self):
self.make_member('crusher', 150)
self.make_member('bruiser', 250)
self.enterprise.set_take_for(self.picard, D('0.01'), self.picard)
with pytest.raises(NotAllowed):
self.enterprise.set_take_for(self.picard, 50, self.picard)
return # XXX allow owners to join teams!
self.enterprise.set_take_for(self.picard, 50, self.picard)
self.run_through_takes()
assert P('crusher').balance == D('150.00')
assert P('bruiser').balance == D('250.00')
Expand Down

0 comments on commit 0b88b4d

Please sign in to comment.