forked from rDrama/rDrama
make inifnite currency work again
parent
e5604b7ad5
commit
9d93f521a3
|
@ -224,17 +224,18 @@ class User(Base):
|
||||||
if SITE == 'rdrama.net' and self.id == 5237:
|
if SITE == 'rdrama.net' and self.id == 5237:
|
||||||
return
|
return
|
||||||
|
|
||||||
user_query = g.db.query(User).options(load_only(User.id)).filter_by(id=self.id)
|
if self.admin_level < PERMS['INFINITE_CURRENCY']:
|
||||||
|
user_query = g.db.query(User).options(load_only(User.id)).filter_by(id=self.id)
|
||||||
|
|
||||||
if currency == 'coins':
|
if currency == 'coins':
|
||||||
try:
|
try:
|
||||||
user_query.update({ User.coins: User.coins + amount })
|
user_query.update({ User.coins: User.coins + amount })
|
||||||
except OperationalError as e:
|
except OperationalError as e:
|
||||||
if str(e).startswith('(psycopg2.errors.QueryCanceled) canceling statement due to statement timeout'):
|
if str(e).startswith('(psycopg2.errors.QueryCanceled) canceling statement due to statement timeout'):
|
||||||
abort(409, f"Statement timeout while trying to pay @{self.username} {amount} coins!")
|
abort(409, f"Statement timeout while trying to pay @{self.username} {amount} coins!")
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
user_query.update({ User.marseybux: User.marseybux + amount })
|
user_query.update({ User.marseybux: User.marseybux + amount })
|
||||||
|
|
||||||
if reason and amount:
|
if reason and amount:
|
||||||
currency_log = CurrencyLog(
|
currency_log = CurrencyLog(
|
||||||
|
@ -254,21 +255,24 @@ class User(Base):
|
||||||
|
|
||||||
should_check_balance = kwargs.get('should_check_balance', True)
|
should_check_balance = kwargs.get('should_check_balance', True)
|
||||||
|
|
||||||
user_query = g.db.query(User).options(load_only(User.id)).filter_by(id=self.id)
|
if self.admin_level < PERMS['INFINITE_CURRENCY']:
|
||||||
|
user_query = g.db.query(User).options(load_only(User.id)).filter_by(id=self.id)
|
||||||
|
|
||||||
logs = []
|
logs = []
|
||||||
if currency == 'coins':
|
if currency == 'coins':
|
||||||
account_balance = self.coins
|
account_balance = self.coins
|
||||||
|
|
||||||
if not should_check_balance or account_balance >= amount:
|
if not should_check_balance or account_balance >= amount:
|
||||||
user_query.update({ User.coins: User.coins - amount })
|
if self.admin_level < PERMS['INFINITE_CURRENCY']:
|
||||||
|
user_query.update({ User.coins: User.coins - amount })
|
||||||
succeeded = True
|
succeeded = True
|
||||||
logs = [['coins', amount]]
|
logs = [['coins', amount]]
|
||||||
elif currency == 'marseybux':
|
elif currency == 'marseybux':
|
||||||
account_balance = self.marseybux
|
account_balance = self.marseybux
|
||||||
|
|
||||||
if not should_check_balance or account_balance >= amount:
|
if not should_check_balance or account_balance >= amount:
|
||||||
user_query.update({ User.marseybux: User.marseybux - amount })
|
if self.admin_level < PERMS['INFINITE_CURRENCY']:
|
||||||
|
user_query.update({ User.marseybux: User.marseybux - amount })
|
||||||
succeeded = True
|
succeeded = True
|
||||||
logs = [['marseybux', amount]]
|
logs = [['marseybux', amount]]
|
||||||
elif currency == 'coins/marseybux':
|
elif currency == 'coins/marseybux':
|
||||||
|
@ -281,10 +285,11 @@ class User(Base):
|
||||||
if subtracted_coins > self.coins:
|
if subtracted_coins > self.coins:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
user_query.update({
|
if self.admin_level < PERMS['INFINITE_CURRENCY']:
|
||||||
User.marseybux: User.marseybux - subtracted_mbux,
|
user_query.update({
|
||||||
User.coins: User.coins - subtracted_coins,
|
User.marseybux: User.marseybux - subtracted_mbux,
|
||||||
})
|
User.coins: User.coins - subtracted_coins,
|
||||||
|
})
|
||||||
succeeded = True
|
succeeded = True
|
||||||
logs = [['coins', subtracted_coins], ['marseybux', subtracted_mbux]]
|
logs = [['coins', subtracted_coins], ['marseybux', subtracted_mbux]]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue