Fixed race condition when transacting to own user
This commit is contained in:
parent
16cfd63e4a
commit
f432ffc70b
|
@ -59,13 +59,14 @@ class VirtualTransaction(models.Model):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def moveMoney(fromUser, toUser, amount, commit=True):
|
def moveMoney(fromUser, toUser, amount, commit=True):
|
||||||
fromProfile = fromUser.get_profile()
|
if fromUser != toUser:
|
||||||
toProfile = toUser.get_profile()
|
fromProfile = fromUser.get_profile()
|
||||||
fromProfile.balance -= amount
|
toProfile = toUser.get_profile()
|
||||||
toProfile.balance += amount
|
fromProfile.balance -= amount
|
||||||
if commit:
|
toProfile.balance += amount
|
||||||
fromProfile.save()
|
if commit:
|
||||||
toProfile.save()
|
fromProfile.save()
|
||||||
|
toProfile.save()
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.user and self.recipient:
|
if self.user and self.recipient:
|
||||||
|
|
Loading…
Reference in New Issue