Browse Source

Fixed race condition when transacting to own user

master
Sebastian Lohff 11 years ago
parent
commit
f432ffc70b
  1. 15
      k4ever/transaction/models.py

15
k4ever/transaction/models.py

@ -59,13 +59,14 @@ class VirtualTransaction(models.Model): @@ -59,13 +59,14 @@ class VirtualTransaction(models.Model):
@staticmethod
def moveMoney(fromUser, toUser, amount, commit=True):
fromProfile = fromUser.get_profile()
toProfile = toUser.get_profile()
fromProfile.balance -= amount
toProfile.balance += amount
if commit:
fromProfile.save()
toProfile.save()
if fromUser != toUser:
fromProfile = fromUser.get_profile()
toProfile = toUser.get_profile()
fromProfile.balance -= amount
toProfile.balance += amount
if commit:
fromProfile.save()
toProfile.save()
def save(self, *args, **kwargs):
if self.user and self.recipient:

Loading…
Cancel
Save