コード例 #1
0
def update_amount(category_id, amount, delta):
    """Updates asset amount and returns the new amount"""
    session = Session()

    asset = _get_or_create_asset(
        session=session,
        category_id=category_id,
    )

    if delta:
        amount = asset.amount + amount
    if amount < 0:
        raise NotEnoughAssetAmount()
    asset.amount = amount
    if asset.amount == 0:
        session.delete(asset)
    session.commit()
コード例 #2
0
def removeKarmaReaction(serverId: str, kr: str):
    ses = Session()
    kr = getKarmaReactionByServerAndReaction(serverId, kr, ses)
    ses.delete(kr)
    ses.commit()