use charge_account everywhere
parent
905b070437
commit
6d636e4e42
|
@ -103,7 +103,8 @@ def purchase_lottery_tickets(v, quantity=1):
|
||||||
if (most_recent_lottery is None):
|
if (most_recent_lottery is None):
|
||||||
return False, "There is no active lottery."
|
return False, "There is no active lottery."
|
||||||
|
|
||||||
v.charge_account('coins', LOTTERY_TICKET_COST * quantity)
|
if not v.charge_account('coins', LOTTERY_TICKET_COST * quantity):
|
||||||
|
return False, "You don't have enough coins"
|
||||||
v.currently_held_lottery_tickets += quantity
|
v.currently_held_lottery_tickets += quantity
|
||||||
v.total_held_lottery_tickets += quantity
|
v.total_held_lottery_tickets += quantity
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,6 @@ def shop(v):
|
||||||
@auth_required
|
@auth_required
|
||||||
@feature_required('AWARDS')
|
@feature_required('AWARDS')
|
||||||
def buy(v, award):
|
def buy(v, award):
|
||||||
|
|
||||||
|
|
||||||
if award == 'benefactor' and not request.values.get("mb"):
|
if award == 'benefactor' and not request.values.get("mb"):
|
||||||
abort(403, "You can only buy the Benefactor award with marseybux.")
|
abort(403, "You can only buy the Benefactor award with marseybux.")
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ def vote_option(option_id, v):
|
||||||
abort(403, f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}")
|
abort(403, f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}")
|
||||||
|
|
||||||
if option.exclusive == 2:
|
if option.exclusive == 2:
|
||||||
if v.coins < POLL_BET_COINS: abort(400, f"You don't have {POLL_BET_COINS} coins!")
|
if not v.charge_account('coins', POLL_BET_COINS):
|
||||||
v.charge_account('coins', POLL_BET_COINS)
|
abort(400, f"You don't have {POLL_BET_COINS} coins!")
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
autojanny = get_account(AUTOJANNY_ID)
|
autojanny = get_account(AUTOJANNY_ID)
|
||||||
autojanny.coins += POLL_BET_COINS
|
autojanny.coins += POLL_BET_COINS
|
||||||
|
|
|
@ -774,10 +774,7 @@ def submit_post(v, sub=None):
|
||||||
|
|
||||||
if embed and len(embed) > 1500: embed = None
|
if embed and len(embed) > 1500: embed = None
|
||||||
|
|
||||||
if request.values.get("ghost") and v.coins >= 100:
|
ghost = request.values.get("ghost") and v.charge_account('coins', 100)
|
||||||
v.charge_account('coins', 100)
|
|
||||||
ghost = True
|
|
||||||
else: ghost = False
|
|
||||||
|
|
||||||
if embed: embed = embed.strip()
|
if embed: embed = embed.strip()
|
||||||
|
|
||||||
|
|
|
@ -274,9 +274,10 @@ def settings_profile_post(v):
|
||||||
if v.house: cost = 2000
|
if v.house: cost = 2000
|
||||||
else: cost = 500
|
else: cost = 500
|
||||||
|
|
||||||
if v.coins >= cost: v.charge_account('coins', cost)
|
success = v.charge_account('coins', cost)
|
||||||
elif v.procoins >= cost: v.charge_account('procoins', cost)
|
if not success:
|
||||||
else: abort(403)
|
success = v.charge_account('procoins', cost)
|
||||||
|
if not success: abort(403)
|
||||||
|
|
||||||
if house == "None": house = ''
|
if house == "None": house = ''
|
||||||
v.house = house
|
v.house = house
|
||||||
|
|
|
@ -329,10 +329,9 @@ def create_sub2(v):
|
||||||
|
|
||||||
sub = get_sub_by_name(name, graceful=True)
|
sub = get_sub_by_name(name, graceful=True)
|
||||||
if not sub:
|
if not sub:
|
||||||
if v.coins < HOLE_COST:
|
if not v.charge_account('coins', HOLE_COST):
|
||||||
return render_template("sub/create_hole.html", v=v, cost=HOLE_COST, error="You don't have enough coins!"), 403
|
return render_template("sub/create_hole.html", v=v, cost=HOLE_COST, error="You don't have enough coins!"), 403
|
||||||
|
|
||||||
v.charge_account('coins', HOLE_COST)
|
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
if v.shadowbanned: return {"error": "Internal Server Error"}, 500
|
if v.shadowbanned: return {"error": "Internal Server Error"}, 500
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,6 @@ def transfer_currency(v:User, username:str, currency_name:Literal['coins', 'proc
|
||||||
amount = int(amount) if amount.isdigit() else None
|
amount = int(amount) if amount.isdigit() else None
|
||||||
|
|
||||||
if amount is None or amount <= 0: abort(400, f"Invalid number of {friendly_currency_name}")
|
if amount is None or amount <= 0: abort(400, f"Invalid number of {friendly_currency_name}")
|
||||||
if v.coins < amount: abort(400, f"You don't have enough {friendly_currency_name}")
|
|
||||||
if amount < MIN_CURRENCY_TRANSFER: abort(400, f"You have to gift at least {MIN_CURRENCY_TRANSFER} {friendly_currency_name}")
|
if amount < MIN_CURRENCY_TRANSFER: abort(400, f"You have to gift at least {MIN_CURRENCY_TRANSFER} {friendly_currency_name}")
|
||||||
tax = 0
|
tax = 0
|
||||||
if apply_tax and not v.patron and not receiver.patron and not v.alts_patron and not receiver.alts_patron:
|
if apply_tax and not v.patron and not receiver.patron and not v.alts_patron and not receiver.alts_patron:
|
||||||
|
@ -281,11 +280,15 @@ def transfer_currency(v:User, username:str, currency_name:Literal['coins', 'proc
|
||||||
reason = request.values.get("reason", "").strip()
|
reason = request.values.get("reason", "").strip()
|
||||||
log_message = f"@{v.username} has transferred {amount} {friendly_currency_name} to @{receiver.username}"
|
log_message = f"@{v.username} has transferred {amount} {friendly_currency_name} to @{receiver.username}"
|
||||||
notif_text = f":marseycapitalistmanlet: @{v.username} has gifted you {amount-tax} {friendly_currency_name}!"
|
notif_text = f":marseycapitalistmanlet: @{v.username} has gifted you {amount-tax} {friendly_currency_name}!"
|
||||||
|
|
||||||
if reason:
|
if reason:
|
||||||
if len(reason) > TRANSFER_MESSAGE_LENGTH_LIMIT: abort(400, f"Reason is too long, max {TRANSFER_MESSAGE_LENGTH_LIMIT} characters")
|
if len(reason) > TRANSFER_MESSAGE_LENGTH_LIMIT: abort(400, f"Reason is too long, max {TRANSFER_MESSAGE_LENGTH_LIMIT} characters")
|
||||||
notif_text += f"\n\n> {reason}"
|
notif_text += f"\n\n> {reason}"
|
||||||
log_message += f"\n\n> {reason}"
|
log_message += f"\n\n> {reason}"
|
||||||
v.charge_account(currency_name, amount)
|
|
||||||
|
if not v.charge_account(currency_name, amount):
|
||||||
|
abort(400, f"You don't have enough {friendly_currency_name}")
|
||||||
|
|
||||||
if not v.shadowbanned:
|
if not v.shadowbanned:
|
||||||
receiver.coins += amount - tax
|
receiver.coins += amount - tax
|
||||||
g.db.add(receiver)
|
g.db.add(receiver)
|
||||||
|
|
Loading…
Reference in New Issue