make hat designers gets their own hat for free

remotes/1693045480750635534/spooky-22
Aevann1 2022-09-05 09:59:24 +02:00
parent 64f95f1fca
commit b166fdcaf3
2 changed files with 12 additions and 7 deletions

View File

@ -290,17 +290,23 @@ def comment(v):
copyfile(oldname, filename)
process_image(filename, 200)
hat = HatDef(
hat_def = HatDef(
name=name,
description=hat["description"],
author_id=user.id,
price=hat["price"]
)
g.db.add(hat_def)
g.db.flush()
hat = Hat(
user_id=user.id,
hat_id=hat_def.id
)
g.db.add(hat)
all_by_author = g.db.query(HatDef).filter_by(author_id=user.id).count()
# off-by-one: newly added hat isn't counted
if all_by_author >= 250:
badge_grant(badge_id=166, user=user)
elif all_by_author >= 100:

View File

@ -58,11 +58,10 @@ def buy_hat(v, hat_id):
g.db.add(v)
g.db.add(hat.author)
if v.id != hat.author.id:
send_repeatable_notification(
hat.author.id,
f":marseycapitalistmanlet: @{v.username} has just bought `{hat.name}`, you have received your 10% cut ({int(hat.price * 0.1)} {currency}) :!marseycapitalistmanlet:"
)
send_repeatable_notification(
hat.author.id,
f":marseycapitalistmanlet: @{v.username} has just bought `{hat.name}`, you have received your 10% cut ({int(hat.price * 0.1)} {currency}) :!marseycapitalistmanlet:"
)
if v.num_of_owned_hats >= 250:
badge_grant(user=v, badge_id=154)