Skip to content

Commit

Permalink
update giving/receiving after payins and payouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Aug 29, 2015
1 parent 274f712 commit 5035b15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions liberapay/billing/exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,10 @@ def propagate_exchange(cursor, participant, route, error, amount):
if amount < 0 and new_balance < 0:
raise NegativeBalance

if hasattr(participant, 'set_attributes'):
participant.set_attributes(balance=new_balance)
participant.set_attributes(balance=new_balance)

if amount != 0:
participant.update_giving_and_tippees(cursor)


def transfer(db, tipper, tippee, amount, context, **kw):
Expand Down
9 changes: 4 additions & 5 deletions liberapay/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,11 +928,10 @@ def update_status(self, status, cursor=None):
elif status == 'active':
self.update_goal(None, c)

def update_giving_and_tippees(self):
with self.db.get_cursor() as cursor:
updated_tips = self.update_giving(cursor)
for tip in updated_tips:
Participant.from_id(tip.tippee).update_receiving(cursor)
def update_giving_and_tippees(self, cursor):
updated_tips = self.update_giving(cursor)
for tip in updated_tips:
Participant.from_id(tip.tippee).update_receiving(cursor)

def update_giving(self, cursor=None):
# Update is_funded on tips
Expand Down

0 comments on commit 5035b15

Please sign in to comment.