From 476d6994b4a0dd85a9482499e910d91d399b227b Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 12 Jan 2024 10:12:35 +0200 Subject: [PATCH] fix this https://watchpeopledie.tv/h/meta/post/61549/megathread-for-bugs-and-suggestions/2448691#context --- files/assets/js/award_modal.js | 12 ++++++++++-- files/classes/user.py | 2 +- files/helpers/alerts.py | 4 ++-- files/routes/awards.py | 4 ++-- files/routes/groups.py | 2 +- files/routes/hats.py | 2 +- files/routes/holes.py | 2 +- files/routes/polls.py | 4 ++-- files/routes/settings.py | 2 +- files/templates/modals/award.html | 11 ++++++++++- 10 files changed, 31 insertions(+), 14 deletions(-) diff --git a/files/assets/js/award_modal.js b/files/assets/js/award_modal.js index 1cb21364f..412ae80c4 100644 --- a/files/assets/js/award_modal.js +++ b/files/assets/js/award_modal.js @@ -91,6 +91,7 @@ function vote(type, id, dir) { } let global_price; +let global_currency; const note_section = document.getElementById('note_section') const gif_button = note_section.querySelector('[title="Add GIF"]') @@ -153,13 +154,20 @@ function pick(kind, price, coins, marseybux) { const ownednum = Number(document.getElementById(`${kind}-owned`).textContent); + if (kind == 'grass') + global_currency = 'coins' + else if (kind == 'benefactor') + global_currency = 'marseybux' + else + global_currency = 'coins/marseybux' + if (ownednum > 0) { document.getElementById('award_price').textContent = `${ownednum} owned`; giveaward_button.classList.remove('d-none'); document.getElementById('buyandgiveaward').classList.add('d-none'); } else { - document.getElementById('award_price').textContent = `Price: ${price} coins/marseybux`; + document.getElementById('award_price').textContent = `Price: ${price} ${global_currency}`; giveaward_button.classList.add('d-none'); document.getElementById('buyandgiveaward').classList.remove('d-none'); } @@ -188,7 +196,7 @@ function giveaward(t) { } else { ownedblock.textContent = `Price: ${global_price}` - document.getElementById('award_price').textContent = `Price: ${global_price} coins/marseybux`; + document.getElementById('award_price').textContent = `Price: ${global_price} ${global_currency}`; } } ); diff --git a/files/classes/user.py b/files/classes/user.py index dd9560110..55587b250 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -238,7 +238,7 @@ class User(Base): if not should_check_balance or account_balance >= amount: user_query.update({ User.marseybux: User.marseybux - amount }) succeeded = True - elif currency == 'combined': + elif currency == 'coins/marseybux': if self.marseybux >= amount: subtracted_mbux = amount subtracted_coins = 0 diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index cae4abce7..6d4db52c6 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -180,7 +180,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr if cost > v.coins + v.marseybux: abort(403, f"You need {cost} currency to mention these ping groups!") - v.charge_account('combined', cost) + v.charge_account('coins/marseybux', cost) if obj: obj.ping_cost += cost return 'everyone' @@ -223,7 +223,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr coin_receivers.update(member_ids) if cost: - v.charge_account('combined', cost) + v.charge_account('coins/marseybux', cost) if obj: obj.ping_cost += cost diff --git a/files/routes/awards.py b/files/routes/awards.py index 029151df4..48f2f4ed5 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -62,11 +62,11 @@ def buy_award(v, kind, AWARDS): elif kind == "benefactor": currency = 'marseybux' else: - currency = 'combined' + currency = 'coins/marseybux' charged = v.charge_account(currency, price) if not charged[0]: - abort(400, "Not enough coins/marseybux!") + abort(400, f"Not enough {currency}!") v.coins_spent += charged[1] if v.coins_spent >= 1000000: diff --git a/files/routes/groups.py b/files/routes/groups.py index 64f9ebf9c..7515afb4c 100644 --- a/files/routes/groups.py +++ b/files/routes/groups.py @@ -35,7 +35,7 @@ def create_group(v): if name in {'everyone', 'jannies', 'holejannies', 'followers', 'commenters'} or g.db.get(Group, name): abort(400, "This group already exists!") - if not v.charge_account('combined', GROUP_COST)[0]: + if not v.charge_account('coins/marseybux', GROUP_COST)[0]: abort(403, "You don't have enough coins or marseybux!") g.db.add(v) diff --git a/files/routes/hats.py b/files/routes/hats.py index b01f57bfa..ee7bd43b7 100644 --- a/files/routes/hats.py +++ b/files/routes/hats.py @@ -85,7 +85,7 @@ def buy_hat(v, hat_id): if not hat.is_purchasable: abort(403, "This hat is not for sale!") - charged = v.charge_account('combined', hat.price) + charged = v.charge_account('coins/marseybux', hat.price) if not charged[0]: abort(400, "Not enough coins/marseybux!") diff --git a/files/routes/holes.py b/files/routes/holes.py index d79549399..67006d27e 100644 --- a/files/routes/holes.py +++ b/files/routes/holes.py @@ -372,7 +372,7 @@ def create_sub2(v): if not hole_group_name_regex.fullmatch(name): abort(400, "Name does not match the required format!") - if not v.charge_account('combined', HOLE_COST)[0]: + if not v.charge_account('coins/marseybux', HOLE_COST)[0]: abort(400, "You don't have enough coins or marseybux!") hole = get_hole(name, graceful=True) diff --git a/files/routes/polls.py b/files/routes/polls.py index 6f37aa3f4..22a16b44f 100644 --- a/files/routes/polls.py +++ b/files/routes/polls.py @@ -26,7 +26,7 @@ def vote_option(option_id, v): if option.exclusive == 2: if option.parent.total_bet_voted(v): abort(403, "You can't participate in a closed bet!") - if not v.charge_account('combined', POLL_BET_COINS)[0]: + if not v.charge_account('coins/marseybux', POLL_BET_COINS)[0]: abort(400, f"You don't have {POLL_BET_COINS} coins or marseybux!") g.db.add(v) @@ -79,7 +79,7 @@ def vote_option_comment(option_id, v): if option.exclusive == 2: if option.parent.total_bet_voted(v): abort(403, "You can't participate in a closed bet!") - if not v.charge_account('combined', POLL_BET_COINS)[0]: + if not v.charge_account('coins/marseybux', POLL_BET_COINS)[0]: abort(400, f"You don't have {POLL_BET_COINS} coins or marseybux!") g.db.add(v) diff --git a/files/routes/settings.py b/files/routes/settings.py index bab6e4403..01d862739 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -365,7 +365,7 @@ def settings_personal_post(v): else: cost = HOUSE_JOIN_COST - success = v.charge_account('combined', cost)[0] + success = v.charge_account('coins/marseybux', cost)[0] if not success: abort(403) if house == "None": house = '' diff --git a/files/templates/modals/award.html b/files/templates/modals/award.html index 8eae9fb91..5317ad062 100644 --- a/files/templates/modals/award.html +++ b/files/templates/modals/award.html @@ -22,7 +22,16 @@ {% macro iterate_awards(awards) %} {% for award in awards %} {% set price = (award.price*v.award_discount)|int %} -
+ + {% if award.kind == 'grass' %} + {% set currency = 'coins' %} + {% elif award.kind == 'benefactor' %} + {% set currency = 'marseybux' %} + {% else %} + {% set currency = 'coins/marseybux' %} + {% endif %} + +
{{award.title}}
{{award.owned}}