forked from rDrama/rDrama
Formalize unpurchasable hats.
parent
bfb13e9fec
commit
d7aaa33c7f
|
@ -36,6 +36,12 @@ class HatDef(Base):
|
|||
def censored_description(self, v):
|
||||
return censor_slurs(self.description, v)
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def is_purchasable(self):
|
||||
return self.price > 0
|
||||
|
||||
|
||||
class Hat(Base):
|
||||
__tablename__ = "hats"
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@ def buy_hat(v, hat_id):
|
|||
existing = g.db.query(Hat).filter_by(user_id=v.id, hat_id=hat.id).one_or_none()
|
||||
if existing: abort(400, "You already own this hat!")
|
||||
|
||||
if not hat.is_purchasable:
|
||||
abort(403, "This hat is not for sale.")
|
||||
|
||||
if request.values.get("mb"):
|
||||
charged = v.charge_account('procoins', hat.price)
|
||||
if not charged: abort(400, "Not enough marseybux.")
|
||||
|
|
|
@ -120,7 +120,7 @@
|
|||
<td><a href="/hat_owners/{{hat.id}}">{{hat.number_sold}}</a></td>
|
||||
<td>{{hat.price}}</td>
|
||||
<td class="shop-table-actions" style="width:unset">
|
||||
{% if hat.id not in owned_hat_ids %}
|
||||
{% if hat.id not in owned_hat_ids and hat.is_purchasable %}
|
||||
<div id="if-not-owned-{{hat.id}}">
|
||||
<button type="button" id="buy1-{{hat.id}}" class="btn btn-success {% if v.coins < hat.price %}disabled{% endif %}" data-click="postToast(this, '/buy_hat/{{hat.id}}', 'if-not-owned-{{hat.id}}', 'if-owned-{{hat.id}}', 'd-none', (xhr)=>{if(xhr.status == 200)document.getElementById('user-coins-amount').innerHTML-={{hat.price}}})" onclick="areyousure(this)"><span class="m-auto">Buy</span></button>
|
||||
|
||||
|
|
Loading…
Reference in New Issue