forked from brmlab/brmbar-github
brmbar-qt4: Add LIMIT_BALANCE(=-200) as a lower limit of user credit
This commit is contained in:
parent
84881dece3
commit
1c0e51a246
2 changed files with 15 additions and 0 deletions
|
@ -8,6 +8,9 @@ from brmbar import Database
|
|||
|
||||
import brmbar
|
||||
|
||||
# User credit balance limit; sale will fail when balance is below this limit.
|
||||
LIMIT_BALANCE = -200
|
||||
|
||||
|
||||
class ShopAdapter(QtCore.QObject):
|
||||
""" Interface between QML and the brmbar package """
|
||||
|
@ -70,6 +73,11 @@ class ShopAdapter(QtCore.QObject):
|
|||
db.commit()
|
||||
return acct
|
||||
|
||||
@QtCore.Slot('QVariant', 'QVariant', result='QVariant')
|
||||
def canSellItem(self, itemid, userid):
|
||||
user = brmbar.Account.load(db, id = userid)
|
||||
return -user.balance() > LIMIT_BALANCE
|
||||
|
||||
@QtCore.Slot('QVariant', 'QVariant', result='QVariant')
|
||||
def sellItem(self, itemid, userid):
|
||||
user = brmbar.Account.load(db, id = userid)
|
||||
|
@ -99,6 +107,11 @@ class ShopAdapter(QtCore.QObject):
|
|||
db.commit()
|
||||
return balance
|
||||
|
||||
@QtCore.Slot('QVariant', result='QVariant')
|
||||
def balance_user(self, userid):
|
||||
user = brmbar.Account.load(db, id=userid)
|
||||
return user.negbalance_str()
|
||||
|
||||
@QtCore.Slot(result='QVariant')
|
||||
def balance_cash(self):
|
||||
balance = shop.cash.balance_str()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue