allow ppl to make ping groups w/ mbux

master
Aevann 2023-03-07 07:06:17 +02:00
parent 964a3d3883
commit 1025c32322
3 changed files with 18 additions and 4 deletions

View File

@ -225,6 +225,20 @@ class User(Base):
if not should_check_balance or account_balance >= amount:
g.db.query(User).filter(User.id == self.id).update({ User.marseybux: User.marseybux - amount })
succeeded = True
elif currency == 'combined':
mbux = in_db.marseybux
needed_coins = 0
if mbux < amount:
needed_coins = amount - mbux
if in_db.coins < needed_coins:
return False
g.db.query(User).filter(User.id == self.id).update({
User.marseybux: User.marseybux - mbux,
User.coins: User.coins - needed_coins,
})
succeeded = True
if succeeded:
g.db.add(self)

View File

@ -34,8 +34,8 @@ def create_group(v):
if name == 'everyone' or g.db.get(Group, name):
return redirect(f"/ping_groups?error=This group already exists!")
if not v.charge_account('coins', GROUP_COST):
return redirect(f"/ping_groups?error=You don't have enough coins!")
if not v.charge_account('combined', GROUP_COST):
return redirect(f"/ping_groups?error=You don't have enough coins or marseybux!")
g.db.add(v)
if v.shadowbanned: abort(500)

View File

@ -59,9 +59,9 @@
<span class="text-danger text-small" style="vertical-align: sub;">{{error}}</span>
</p>
{% endif %}
<button type="submit" class="btn btn-primary ml-auto" {% if v.coins < cost %}disabled{% endif %}>Create Group</button>
<button type="submit" class="btn btn-primary ml-auto" {% if v.marseybux + v.coins < cost %}disabled{% endif %}>Create Group</button>
</div>
<p class="mt-2 mr-1" style="float: right"><b>Cost</b>: {{cost}} coins</p>
<p class="mt-2 mr-1" style="float: right"><b>Cost</b>: {{cost}} coins or marseybux</p>
</div>
</div>
</div>